I’m using the gallery to access images to upload. I’m having no trouble when I am uploading the image uri directly, but when I need to use fileEntry (for multi-part uploads) jpgs are not returning a fileEntry from their uri. Note: i’m using async:await, but I have the same issue with standard promises
For example the following is the code I’m using to get the image uri
var imageUri = await this.takePicture(Object.assign(this.defaultOptions,{sourceType:this.camera.PictureSourceType.SAVEDPHOTOALBUM}));
let newFile = new File([imageUri], "filename");
this.uploadFile(newFile);
The following is the code for takePicture() that returns the imageUri
try{
return await this.camera.getPicture(options);
}catch(err){
...handle error
}
This code above successfully uploads both png and jpg files.
This code below fails to retrieve a fileEntry for only jpg files.
/**
* Returns a file entry for the image uri provided
* @param imgUri image Uri to get file entry for
*/
private async getFileFromImageUri(imgUri){
try{
var fileEntry = await this.resolveFileAsPromise(imgUri);
}catch(err){
// fileEntry = await this.createNewFileEntry(imgUri);
this.presentToast('Error while selecting image.'); //TODO: images that are .jpg seem to have trouble being resolved to a file.
}
return fileEntry;
}
resolveFileAsPromise(ImgUri);
is a promise wrapper for window.resolveLocalFileSystemURL(imgUri, resolve, reject);
It returns the following error
FileError {code: 5}
for jpgs only.
Has anyone encountered this issue? I am testing on a live android device (not an emulator).
I feel that the above demonstrates that the image uri is not the problem since it works to upload images when I don’t need to get to the fileEntry. But, when I do, it works for only a particular filetype pngs.