Description
Calling Ti.Media.saveToPhotoGallery() throws the following error, running through VS gives more detail and I believe the cause is [to_path here](
https://github.com/appcelerator/titanium_mobile_windows/blob/7f4b3efcac026b1b6037b59ad1904556c826db21/Source/Media/src/Media.cpp#L377) is null, so the to convert string call is returning an empty string, which then causes an error in the copy call. I believe this is because the Library folders are virtualized [read here](
https://stackoverflow.com/questions/38874259/windows-storage-knownfolders-musiclibrary-path-returns-empty) so they don't have a path, we might need to do something like [this](
https://github.com/Microsoft/Windows-universal-samples/blob/6370138b150ca8a34ff86de376ab6408c5587f5d/Samples/FileAccess/cpp/Scenario1_CreateAFileInThePicturesLibrary.xaml.cpp#L31-L48) to first find the folder for a user, then write to that folder
[ERROR] ----- Titanium Javascript Runtime Error -----
[ERROR] In app.js: 14,28
[ERROR] Message: Uncaught Error: saveToPhotoGallery: unknown exception
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({
backgroundColor: 'red',
width: 400,
height: 400,
borderRadius: 200
});
win.add(view);
win.open();
var file = Ti.Filesystem.getFile('Logo.png')
Ti.Media.saveToPhotoGallery(file, {
success: function (e) {
// log.args('Ti.Media', 'Image saved to photo-gallery successfully!');
console.log('image done');
},
error: function (e) {
// log.args('Ti.Media', 'Error saving image to photo-gallery: ' + e.error);
console.log(JSON.stringify(e))
console.log('image ');
}
});
Steps to reproduce
Add the above to an existing app.js and build for Windows
Actual
Error thrown
Expected
Image should be written to gallery
https://github.com/appcelerator/titanium_mobile_windows/pull/1127
Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.