Copy image from app sandbox to app folder

Hi everyone,

now i have the code to download an image from a remote server, and store it on app sandbox, but i need to move it to the app folder.

In the end of this link, there are one example to move an image from sandbox to app folder.

https://docs.coronalabs.com/guide/data/readWriteFiles/index.html

I am using it, but it don’t work. Other problem is that system.ResourceDirectory is the directory of the sandbox app, and the system.DocumentsDirectory is the app folder. But when i test it, it is the opposite, the system.ResourceDirectory refers to the app folder and system.DocumentsDirectory is the sandbox folder.

And because of that i can’t move my image.

Here is a link to the dropbox, pls check the small piece of code doing what i said bellow.

https://www.dropbox.com/s/vxfdxpagskps34b/DownloadFolder.zip?dl=0

Grettings

you can’t move from your sandbox to your app folder, as far as i know, for security reasons.

so, how can i download images from a remote server and use them on my app?

Hi @Anfirous,

The first thing is to clarify what these “folders” are and the restrictions upon them.

  1. The app’s resource directory (system.ResourceDirectory) is the “package” that is compiled when you build the app from the Corona Simulator. This includes assets and files which are pre-bundled when you perform the build. You can not write files to this folder under any circumstances, for security reasons.

  2. The app’s “documents” directory (system.DocumentsDirectory), or the “caches” or “temporary” folders, are available to you for both reading files and writing files. I suppose this is what you mean by the app’s “sandbox”. You can definitely download images from a remote server, place them in the Documents directory, and use them within the app… this is a fairly common practice.

Hope this helps,

Brent

Thanks for the answer Brent,

i need something really simple, but i don’t know how i can do it.

I only need to download images from remote server to a single folder, and then display the images on the screen.

I can now see the images that i downloaded on the (system.DocumentsDirectory). And i can use them, but i can only see the images on corona simulator, i can’t see per example on droid4x simulator.

On my first topic, i shared a link to my simple code that i am trying to do what i said above, if you can check it, it would be great.

I have a few more days to implement this feature on my app, any help is welcome.

Thanks everyone.

While this tutorial was about copying SQLite databases from system.ResourcesDirectory to system.DocumentsDirectory, but it can be used on any file really.

https://coronalabs.com/blog/2015/05/19/tutorial-initializing-a-writable-sqlite-database-from-a-read-only-database/

Rob

you can’t move from your sandbox to your app folder, as far as i know, for security reasons.

so, how can i download images from a remote server and use them on my app?

Hi @Anfirous,

The first thing is to clarify what these “folders” are and the restrictions upon them.

  1. The app’s resource directory (system.ResourceDirectory) is the “package” that is compiled when you build the app from the Corona Simulator. This includes assets and files which are pre-bundled when you perform the build. You can not write files to this folder under any circumstances, for security reasons.

  2. The app’s “documents” directory (system.DocumentsDirectory), or the “caches” or “temporary” folders, are available to you for both reading files and writing files. I suppose this is what you mean by the app’s “sandbox”. You can definitely download images from a remote server, place them in the Documents directory, and use them within the app… this is a fairly common practice.

Hope this helps,

Brent

Thanks for the answer Brent,

i need something really simple, but i don’t know how i can do it.

I only need to download images from remote server to a single folder, and then display the images on the screen.

I can now see the images that i downloaded on the (system.DocumentsDirectory). And i can use them, but i can only see the images on corona simulator, i can’t see per example on droid4x simulator.

On my first topic, i shared a link to my simple code that i am trying to do what i said above, if you can check it, it would be great.

I have a few more days to implement this feature on my app, any help is welcome.

Thanks everyone.

While this tutorial was about copying SQLite databases from system.ResourcesDirectory to system.DocumentsDirectory, but it can be used on any file really.

https://coronalabs.com/blog/2015/05/19/tutorial-initializing-a-writable-sqlite-database-from-a-read-only-database/

Rob