I am developing a phone-based application that has file transfer functions. I use the camera plugin to select an image file. The code works fine with "DestinationType.DATA_URL". But I can’t access the file named "DestinationType.FILE_URI".
DestinationType.DATA_URL just provides the contents of the image file. But I have to get the image file name and file path along with its contents. Therefore, I have to use "DestinationType.FILE_URI" in the camera settings. Below is my code,
function attachFile() {
var pictureSource=navigator.camera.PictureSourceType;
var cameraOptions = { quality: 49 , destinationType:
Camera.DestinationType.FILE_URI, sourceType: pictureSource.PHOTOLIBRARY };
navigator.camera.getPicture(attachSuccess, attachFail, cameraOptions);
}
function attachSuccess(fileuri) {
filePath = JSON.stringify(fileuri);
console.log("FilePath: "+filePath );
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function attachFail() {
console.log("attach failed");
}
function gotFS(fileSystem) {
console.log("gotFS:");
var root = "/"+fileSystem.root.name;
console.log("root: "+root);
filePath = filePath .substring(filePath.indexOf(root));
var imageName = filePath.substring(filePath.lastIndexOf('/'));
var type = imageName.substring(filePath.indexOf('.'));
fileSystem.root.getFile(filePath, null, gotFileEntry, fail);
}
function fail() {
console.log("** failed **");
}
function gotFileEntry(fileEntry) {
console.log("got file entry");
fileEntry.file(gotFile, fail);
}
function gotFile(file) {
console.log("got file");
}
'attachFile', Get Picture, . attachSuccess. URI . URI FILE , ,
://////5490
, " " "-" URI. , .
( Kitkat Lollipop)