LOAD A IMAGE FROM REMOTE DATABASE SERVER

Hello!

Does anyone know if is possible to load a image from a remote database server…

i 've already develop an application that load some tables contents(varchar contents) through network request to a web service(a php file), but i dont know if its posible to read an image from tha same database server.

thanks! [import]uid: 185094 topic_id: 32105 reply_id: 332105[/import]

network.download()

or

display.loadRemoteImage()

[import]uid: 19626 topic_id: 32105 reply_id: 127900[/import]

i am using display.loadRemoteImage() … i have a question… i have an application developed with storyboard api… i have many scenes! well… i am using the display.loadRemoteImage() only in a single scene… when i leave this scene i destroy the contents of that scene… when i come back i want to rebuild all the contents… for some reason the listener of display.loadRemoteImage() dont execute the second time… have u noticed that?? [import]uid: 185094 topic_id: 32105 reply_id: 127903[/import]

I’ve not noticed that, but before I call display.loadRemoteImage() I check and see if I have the image already in my system.CachesDirectory. I’m using the LFS stuff to see if the file is there, but you can just do a io.open() on the file and see if it exists. If it does, just do a display.newImageRect. If it doesn’t exist, then call display.loadRemoteImage(). The nice thing about using LFS, is you can check the age of the file and maybe re-fetch it after a period of time.
[import]uid: 19626 topic_id: 32105 reply_id: 127909[/import]

network.download()

or

display.loadRemoteImage()

[import]uid: 19626 topic_id: 32105 reply_id: 127900[/import]

i am using display.loadRemoteImage() … i have a question… i have an application developed with storyboard api… i have many scenes! well… i am using the display.loadRemoteImage() only in a single scene… when i leave this scene i destroy the contents of that scene… when i come back i want to rebuild all the contents… for some reason the listener of display.loadRemoteImage() dont execute the second time… have u noticed that?? [import]uid: 185094 topic_id: 32105 reply_id: 127903[/import]

I’ve not noticed that, but before I call display.loadRemoteImage() I check and see if I have the image already in my system.CachesDirectory. I’m using the LFS stuff to see if the file is there, but you can just do a io.open() on the file and see if it exists. If it does, just do a display.newImageRect. If it doesn’t exist, then call display.loadRemoteImage(). The nice thing about using LFS, is you can check the age of the file and maybe re-fetch it after a period of time.
[import]uid: 19626 topic_id: 32105 reply_id: 127909[/import]

@robmiracle I also saw this issue with the cache. Is it means that before load the remote image with code:
[lua]local image1 = display.loadRemoteImage( pictureURL , “GET”, networkListenerIm, “temp.png”, systemTemporaryDirectory )[/lua]

the corona checks if the file “a.png” is in the cache and if it is in, corona doesn’t perform remote load request?

And how looks LFS code you talked about? Thanks [import]uid: 172733 topic_id: 32105 reply_id: 133336[/import]

You can bust the cache using traditional cache busting methods like appending a unique HTTP GET string at the end:

pictureURL = pictureURL .. "?a=" .. os.time()   
local image1 = display.loadRemoteImage( pictureURL , "GET", networkListenerIm, "temp.png", systemTemporaryDirectory )  

That way, every time you request pictureURL, the ?a=somerandomnumber will make it unique and the webserver will throw the ?a= bit away.

As for LFS check out this blog post:

http://www.coronalabs.com/blog/2012/05/08/luafilesystem-lfs-tutorial/

[import]uid: 199310 topic_id: 32105 reply_id: 133365[/import]

@Rob Miracle thanks, it is exactly that I looked for [import]uid: 172733 topic_id: 32105 reply_id: 133385[/import]

@robmiracle I also saw this issue with the cache. Is it means that before load the remote image with code:
[lua]local image1 = display.loadRemoteImage( pictureURL , “GET”, networkListenerIm, “temp.png”, systemTemporaryDirectory )[/lua]

the corona checks if the file “a.png” is in the cache and if it is in, corona doesn’t perform remote load request?

And how looks LFS code you talked about? Thanks [import]uid: 172733 topic_id: 32105 reply_id: 133336[/import]

You can bust the cache using traditional cache busting methods like appending a unique HTTP GET string at the end:

pictureURL = pictureURL .. "?a=" .. os.time()   
local image1 = display.loadRemoteImage( pictureURL , "GET", networkListenerIm, "temp.png", systemTemporaryDirectory )  

That way, every time you request pictureURL, the ?a=somerandomnumber will make it unique and the webserver will throw the ?a= bit away.

As for LFS check out this blog post:

http://www.coronalabs.com/blog/2012/05/08/luafilesystem-lfs-tutorial/

[import]uid: 199310 topic_id: 32105 reply_id: 133365[/import]

@Rob Miracle thanks, it is exactly that I looked for [import]uid: 172733 topic_id: 32105 reply_id: 133385[/import]