Image from file system
Hi, Basically I am trying to store images in appery database as file and the image files' id's in an database table. If image had not been downloaded earlier, I want to download these images to mobile device file system. If file had already been downloaded to the phone, I want to display it in grid. Downlad part is working but I have a problem about displaying downloaded image. It's not loading anyway.
This is page setup.
This is database references.
And finally my code which is getting image id as a value.
precode
function fail(evt) {
alert(evt.target.error.code);
}
var fileUrl = 'https://api.appery.io/rest/1/db/files/' + deneme_settings['database_id'] +"/"+value + "?sessionToken=" + localStorage.getItem('sessionTokenId');
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"SureTerms/"+value, {create: false, exclusive: false},
function gotFileEntry(fileEntry){
$('[dsid=pimage]', element.parent()).attr('src',fileEntry.toURL());
// Appery('pimage').attr('src', ' '+ fileEntry.fullPath+' ');
//$('img[dsid="pimage"]').attr('src',fileEntry.fullPath);
},
function fileDoesNotExist(){
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry){
var sPath = fileEntry.fullPath.replace("dummy.html","");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download(
fileUrl,
sPath + "SureTerms/"+value,
function(theFile) {
$('[dsid=limage]', element.parent()).attr('src',theFile.fullPath);
},
function(error) {
}
);
},
fail);
},
fail);
//fileDoesNotExist
});
},
fail);
/code/pre