cordova-plugin-camera file_uri is different values for same file on selecting again in iOS

291 Views Asked by At

My app uses cordova camera plugin(cordova-plugin-camera) to select files from SAVEDPHOTOALBUM for uploading. This app allows user to select maximum of 3 files one by one and store the FILE_URI in an array. When user selects a file I check if the file path is already in the array and informs the user if he has selected same file again. This validation works fine in Android. But in iOS, I get different FILE_URI for the same file when selected again and the duplicate file selection validation fails. Is there any way to check if the same file is selected again, in iOS.

Please find below code that I am using.

function uploadFromGallery() {
    navigator.camera.getPicture(onSuccess, onFail, {
        quality: 50,
        sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
        mediaType: Camera.MediaType.ALLMEDIA,
        destinationType: Camera.DestinationType.FILE_URI,
        correctOrientation: true
    });
 }

I have tested on iOS 10.2.1 and iOS 11.1 with cordova-plugin-camera version 2.4.1.

Note: I tried changing destinationType to Camera.DestinationType.NATIVE_URI. This gives same path if an image file is selected again, but gives different paths for video files.

0

There are 0 best solutions below