Page 2 of 4

Image from file system

Posted: Thu Nov 28, 2013 9:43 pm
by Maryna Brodina

Don't use prealert(Appery.getImagePath('pimage'));/preAppery.getImagePath returns image path if image is loaded to assets. Delete it and use prealert($("[dsid=pimage]", element.parent()).attr("src"));/pre instead.


Image from file system

Posted: Thu Nov 28, 2013 10:24 pm
by Mehmet Edebali Şener

now it alerts something long which starts with "data:image/png;base64". So i think it correctly assigns file to image element however doesn't show it.


Image from file system

Posted: Fri Nov 29, 2013 10:36 am
by Serhii Kulibaba

Hello Mehmet,

Can you explain, how reproduce this?


Image from file system

Posted: Fri Nov 29, 2013 10:48 am
by Mehmet Edebali Şener

precode
$("[dsid=pimage]", element.parent()).attr("src", evt.target.result);
alert($("[dsid=pimage]", element.parent()).attr("src"));
/code/pre

just I am assigning image element's source then alerting it. It looks like working according to alert however the image not loaded in app anyway.


Image from file system

Posted: Fri Nov 29, 2013 6:15 pm
by Maryna Brodina

Hello! Could you clarify what are the steps to run this code?


Image from file system

Posted: Wed Dec 11, 2013 8:27 am
by Mehmet Edebali Şener

Hi again,

I have some image files and a table that contains the names of those image files in my database. In the response tab of the list query of my table, I am putting the row that contains the names of image file names to an invisible label. In the javascript that assigned to this operation, I want to make:

If the image file is not saved to the phone, first save the image and then show the file,
If the image file is saved before, directly show the file.

In the code, I tried to make the steps mentioned above. I am checking if the file is saved or not. If the file exists (fileExist function), I am assigning the file as the source of that pimage image tag. If the file does not exist(=not saved before) (fileDoesNotExist function), first I am creating a "dummy.html" file and set the file path. Then I am saving the file to that path and assigning the path as the source of pimage image tag. There is no problem about saving or if the file exists to continue by not saving. Even, it seems the image is saved when I tried to alerting the image source, but I couldn't handle to show the image in the phone.

A little cleaned version of code:

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},
//if file exist -BEGIN
function fileExist(fileEntry){
$("[dsid=pimage]", element.parent()).attr("src", fileEntry.toURL());
},
//if file exist -END

//if file does not exist -BEGIN
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();

Code: Select all

                             fileTransfer.download( 
                                 fileUrl, 
                                 sPath + "SureTerms/"+value, 
                                 function(theFile) { 
                                     $('[dsid=pimage]', element.parent()).attr('src', theFile.toURI());  
                                 }, 
                                 function(error) { 
                                 } 
                             ); 
                         },  
                         fail); 
                 },  
                 fail); 

//if file does not exist -END
});
},
fail);

/code/pre


Image from file system

Posted: Wed Dec 11, 2013 10:01 pm
by Maryna Brodina

Hello! Sorry for delay, working on it.


Image from file system

Posted: Thu Dec 12, 2013 7:17 am
by Kateryna Grynko

Hi Mehmet,

Please give us a test login and password with a user has packages. On what OS do you test this?


Image from file system

Posted: Tue Dec 17, 2013 9:56 am
by Mehmet Edebali Şener

Hi,

Sorry for delay i am out of town for some gdg event.

User name = appery
password = 12341234

I'm testing with android device.

After login page you have to select My Packs button.


Image from file system

Posted: Tue Dec 17, 2013 10:12 am
by Maryna Brodina

Hello! Thank you! We'll test and let you know.