语言

Menu
Sites
Language
download image, save its fullPath in indexeddb and display it later

In the future you will be able to store images directly in the db. Tizen currently does not support this. So I am using tizens download api:

var imageDownloadRequest = new tizen.DownloadRequest(uri, "images/speciesImages", filename);
downloadId = tizen.download.start(imageDownloadRequest, downloadListener);

oncompleted: function(id, fullPath) { /*add the path to db */ }
:: Completed with id: 1384877701, full path: images/speciesImages/bird.png

If I now use this given fullPath as the following:

<img src="images/speciesImages/bird.png" />

the image does not display. I can verify that the image is there at it occurs if I browse the emulator via the "My Files" icon. I also tried '/images/...' without success

 

SOLUTION:

use an intermediate call to tizen.filesystem.resolve to get a fileEntry and the use the toURI method in this entry

tizen.filesystem.resolve(fullPath, function(fileEntry){
                        var usableURI = fileEntry.toURI() );
                        /* store this uri in db */
}

 

编辑者为: Thomas Uher 15 11月, 2013

响应

3 回复
Marco Buettner
on img-tag you can not use virtual roots... you have to add /opt/media/
Thomas Uher

Thanks, that should be in the docs of the download api, too!

Thomas Uher

I even think, the download api should offer an additional path which is actually usable in the html as the current value (fullPath in the doc examples) it gives you is not.