#1 2017-01-24 12:35:48

eduardoalfaro
Member
Registered: 2016-06-08
Posts: 37

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

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

Offline

#2 2017-01-24 13:16:29

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

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

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.

Offline

#3 2017-02-10 09:21:15

edunt
Member
Registered: 2015-12-21
Posts: 258

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

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.

Offline

#4 2017-02-10 10:42:41

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

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

Hello,

edunt wrote:

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?

Offline

#5 2017-02-10 11:32:53

fakie
Banned
Registered: 2016-10-28
Posts: 36

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

Is this not a good use of localstorage function

ie.

localStorage.setItem('CurrentSong', this.src);

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


This is my favourite quote.

Offline

#6 2017-02-10 14:01:43

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

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

Hello to all,

fakie wrote:

Is this not a good use of localstorage function

ie.

localStorage.setItem('CurrentSong', this.src);

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.

Offline

#7 2017-02-15 13:19:47

edunt
Member
Registered: 2015-12-21
Posts: 258

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

David wrote:

Hello,

edunt wrote:

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?

Last edited by edunt (2017-02-15 13:20:37)

Offline

#8 2017-02-15 14:30:29

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

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

Hello Edunt,

edunt wrote:
David wrote:

Hello,

edunt wrote:

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.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.