Windows saveToPhotoAlbum:true fails when choosing OneDrive Folders
thorsten-wolf-neptune opened this issue · comments
Bug Report
Problem
When calling
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
saveToPhotoAlbum: true });
on a Windows 10 or Windows 11 UWP app, the user gets a File Promt to choose a location to store the taken picture on his machine.
When selecting a folder that is managed by Microsoft OneDrive the save of the photo fails and you do get a Javascript error
because execution of the following code:
// Prevent updates to the remote version of the file until we're done
Windows.Storage.CachedFileManager.deferUpdates(file);
https://github.com/apache/cordova-plugin-camera/blob/master/src/windows/CameraProxy.js#L810
Throwing an error:
No such interface supported
When choosing a non OneDrive managed Folder the save works just fine.
What is expected to happen?
calling navigator.camera.getPicture on a Windows UWP app with the saveToPhotoAlbum property set to true should allow saving the taken picture in any folder of the device.
What does actually happen?
Saving fails with a Javascript error.
No such interface supported
Information
I tried to surround the call with a try catch and with it would catch the error in a case where the use selects a OneDrive managed folder and it works.
If you want i can create a PR for it:
try {
// Prevent updates to the remote version of the file until we're done
Windows.Storage.CachedFileManager.deferUpdates(file);
} catch (ex) {
// when a one drive folder is selected this function throws an error: "No such interface supported"
// the save still works afterwards so just try and catch it
console.warn(ex);
}
Command or Code
Create an empty Cordova UWP app and execute the following code in the developer tools console:
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
saveToPhotoAlbum: true });
function onSuccess(imageURI) {
debugger;
}
function onFail(message) {
debugger;
alert('Failed because: ' + message);
}
Environment, Platform, Device
Windows UWP app
Version information
Cordova: Cordova CLI 11.1.0
Using cordova-fetch for cordova-windows@^7.0.1
Operating System: Windows 10/11
Other Environment: OneDrive (Personal or Business) problem happens with both
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
Closing because Windows is no longer a supported platform