Download files (images, sounds, videos) from server to APP's folder


Eduardo Alfaro

Hello, maybe one of you have tried this, or know how to accomplish it, thank you in advance.

I am wondering if there is any way to download files (in runtime) from any server (web hosting server) to the APP's folder for later usage. Let me explain better ;-D, I really know we can play a music or video, or read content from a remote url, (example: http://www.myserver.com/file.mp3), but in this scenario the app user will always need an internet connection.

What I am thinking or trying to discover is if there is a possible way to connect to a remote server, download the content (separately or even ZIP o RAR compressed ;-D), and then let the app use the content previously downloaded. So the next time the user opens the app, if there is not internet connection available, the apps will have already some content in local to use.

It will be perfect for downloading updated info, new videos, new audios, wherever… with some code like: Check Internet, connect to a remote server, check if there is new content, download new content, disconnect from server.

Thank you so much!!!
Eduardo


DecSoft

Hello Eduardo,

First of all I have good news, because, with the new Apache Cordova's releases, we can use local audio and video files in addition to remote URLs. In fact I update right now App Builder in order to modify the MediaPlayer's help reference and also the MediaPlayer, SimpleAudio and SimpleVideo samples. These samples uses now app's local files instead of remote URLs. So you can update your App Builder copy and take a look at these samples.

On the other hand, the concept of "download files" doesn't exists for HTML5 applications, since we have no rights to access the user's file system (which probably is good for security reasons). However, Apache Cordova's builded applications can download files and play with then using the File Transfer plugin. This Cordova's plugin is not included "out-of-the-box" in App Builder, but we can use like any other Apache Cordova's plugin.

If you start to implement the File Transfer plugin in your application and need some help, please, don't hesitate to ask here.



Ade Wale

Hi David,
It would be nice to have sample project on file transfer plugin in AB. Because this will make it more powerful and additional feature.


DecSoft

Hello,

Hi David,
It would be nice to have sample project on file transfer plugin in AB. Because this will make it more powerful and additional feature.

I have not time right now, but maybe I can prepare some sample when have some opportunity. But please, ask me this question: are you thinked in some specific kind of files edunt?



Guest

Is this not a good use of localstorage function

ie.

And when no internet connection is found, the last song is played?


DecSoft

Hello to all,

Is this not a good use of localstorage function

ie.

And when no internet connection is found, the last song is played?

App Builder have the SetOption and GetOption actions, which relies in the app's local storage. However the local storage have some limitations around 3/5 MB (in my knowledge) and this maybe can't be sufficient to store files.



Ade Wale
Hello,

Hi David,
It would be nice to have sample project on file transfer plugin in AB. Because this will make it more powerful and additional feature.

I have not time right now, but maybe I can prepare some sample when have some opportunity. But please, ask me this question: are you thinked in some specific kind of files edunt?

Yes, I have specific file. For example: I want client to download *.apk file and install the file their devices, whenever update is available. But I don't want them to use playstore.

The only two ways they can download the file are through playstore and using web browser. Which I don't want them to use it.

How can this be achieveable?


DecSoft

Hello Edunt,

Hello,

Hi David,
It would be nice to have sample project on file transfer plugin in AB. Because this will make it more powerful and additional feature.

I have not time right now, but maybe I can prepare some sample when have some opportunity. But please, ask me this question: are you thinked in some specific kind of files edunt?

Yes, I have specific file. For example: I want client to download *.apk file and install the file their devices, whenever update is available. But I don't want them to use playstore.

The only two ways they can download the file are through playstore and using web browser. Which I don't want them to use it.

How can this be achieveable?

I think there is not easy to download an APK file and then run it: first of all, not all the devices are ready to install applications' APK files, since they must use the different stores. If we avoid this maybe we enters in other problems, because, probably installing an application from another is not the expected behaviour, so may the sytem can say something about.

Anyway, if you want to distribute your applications out of the stores (which is possible and to me acceptable after all) in my opinion you no need to download any APK file, but just look if any new application's release is available. You know that, if we install the application from an store, the store itself is responsible to maintain the application update, based in the app's ID.

Since we can't use the store's updater we may wanted to prepare one for our application (your own case) but to do this maybe its sufficient to check if a new application release exists, and, if exists, just let the user to download and install the new application release. At this point we may use the "OpenWindow" action using the new APK release URL.

Or maybe we can use the "OpenWindow" action to redirect the user to the appropiate website from the new application release can be downloaded. In few words (and this is what I do in your case) we must to check if a new release of the application exists (this is quite easy using an HttpClient control) and then inform the user in order to download and install the new release by itself.

P.S. Certainly, with the help of the Cordova's Files and FileTransfer plugins, maybe it's possible to download an APK (we can download any kind of file in principle) and maybe it's possible to execute it. If you continue wanted something like that, Edunt, I only can refer you to the plugin's documentation, then you can try to implement it. If you have any question or need help during the implementation, please, don't hesitate to post it here or better in a new forum's thread.



DecSoft

Hello to all,

Just to inform that the current release of DecSoft's App Builder added the new FileDownload action, as well the new "FileDownload" app sample. We can use this action to easily download files in both the app private storage or the user device storage.

Hope they can be useful!


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.