Issue description:
We want to be able to download a video file from our servers to the device and save it on the gallery (upon user's approval). On iOS we accomplish this by this code:
var fileName = 'fileToDownload.mp4',
saveToGalleryFlag = true,
videoUrl = 'http://somedomain.com/fileToDownload.mp4';
var xhr = Titanium.Network.createHTTPClient({
onload : function() {
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, fileName);
// write to the file
f.write(this.responseData);
if (saveToGalleryFlag) {
var blob = f.read();
/* According to Titanium docs, this does not save Videos on Android */
Titanium.Media.saveToPhotoGallery(blob, {
success : function(e) {
console.log('-> SUCCESS');
},
error : function(e) {
console.log('-> ERROR', e)
}
});
}
},
timeout : 10000
});
xhr.open('GET', videoUrl);
xhr.file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fileName);
xhr.send();
Expected Result:
Download videos into Android gallery/ file system upon users approval.
master: https://github.com/appcelerator/titanium_mobile/pull/8837
Verified the new feature in SDK 6.1.0.v20170222102258. Works as expected. Closing.