Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Image from file system

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.

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Image from file system

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Image from file system

Hello Mehmet,

Can you explain, how reproduce this?

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Image from file system

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Image from file system

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

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Image from file system

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Image from file system

Hello! Sorry for delay, working on it.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Image from file system

Hi Mehmet,

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

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Image from file system

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Image from file system

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

Return to “Issues”