我正在尝试将使用cordova相机插件捕获的图像保存到Windows 8.1应用程序的特定目录中。但我无法找到一个确切的解决方案。我经历了很多问题和论坛,没有运气。
以下是我尝试的示例代码。
onTakePhoto: function () {
navigator.camera.getPicture(this.onPhotoSuccess, this.onPhotoFail, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.CAMERA,
saveToPhotoAlbum: false
});
},
//Callback function if onTakePhoto action is success.
onPhotoSuccess: function (oImageURI) {
console.log("In Success " + oImageURI);
window.resolveLocalFileSystemURI(oImageURI, this.handlePicSave, this.onPhotoFail);
},
//Callback function if onTakePhoto action fails
onPhotoFail: function (oError) {
console.log("In Fail " + oError);
},
//Handle pic save
handlePicSave: function(oEntry) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSys) {
fileSys.root.getDirectory("MyPhotos", { create: true, exclusive: false }, function (directory) {
oEntry.moveTo(directory, "WO_2.jpg", that.successMove, that.onPhotoFail);
}, that.onPhotoFail);
},
that.onPhotoFail);
},
上面的代码工作正常并将图像保存到app根文件夹,即C:\ Users \ .. \ AppData \ Local \ Packages \ App_name \ LocalState \ MyPhotos \ WO_2.jpg
但是我需要直接存储到C盘,比如.. C:\ MyPhotos \ WO_2.jpg