Discussion Forums  >  Images, Documents, File Locations

Replies: 10    Views: 89

WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
11/29/12 04:07 AM (13 years ago)

Download file on every load

Hi again buzztouchers Would anyone offer me any advice on how to edit my code in android (and ios) so that a certain file in my documents folder gets downloaded automatically every time the user opens the app and has an active internet connection? This will help a lot with my app. Thanks in advance guys Happy learning to all fellow mobile developers....
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
11/29/12 05:38 AM (13 years ago)
Can you point to a URL instead of the downloads folder? Or are you trying to 'update' the local file when the user is online? (In the code itself, you can likely do this by reading the auto-update in the how-to, it shows you where the app update code is.)
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
11/29/12 09:08 AM (13 years ago)
If you right click on the document in your bt documents folder and select copy URL and then copy it to the URL slot instead of the name of your file slot for the document. When the end user restarts the app they will get a pop up starring that there is a content change.
 
Calypso Kid
Aspiring developer
Profile
Posts: 780
Reg: Mar 09, 2012
Upstate New Yor...
18,200
like
11/29/12 09:08 AM (13 years ago)
*stating
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
11/29/12 10:18 AM (13 years ago)
Using a URL for the file is the absolute best way to do it. That way, each time the screen with that file is loaded, it goes out to the URL and grabs (and caches) the latest version. It requires a network connection to get it the first time, but it does get cached in case the next time a network connection is not available. There is no current way to have the file automatically updated when it's updated at the URL. The only way a user will get the most recent version is if they launch that screen. Mark
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
11/30/12 04:59 AM (13 years ago)
@Fingers Crossed: Can you point to a URL instead of the downloads folder? <!-- Nope. I want the file to be completely accessible offline. Like a banner which is used inside a custom html doc which is included in my project. I can even use a local file for the custom html doc. Since it won't change itself. Just the banner or other files addressed by it will change. --> Or are you trying to 'update' the local file when the user is online? <!-- Exactly what I am trying to do; without the user even asking for an update. Then the local html doc file will handle displaying the updated files when called upon. --> (In the code itself, you can likely do this by reading the auto-update in the how-to, it shows you where the app update code is.) <!-- I will do that again to get some more insight on how this works. But as far as I could tell, the files will only get updated if a newer config file is found and the app is refreshed (either manually or by the automatic refresh process you mentioned). So if all is going well and no new config or no refresh, no updated files as well!-->
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
11/30/12 05:06 AM (13 years ago)
@Calypso Kid: Thanks. Did you mean like if the files are hosted on Dropbox? I have done that. It will do that only for newly edited configuration file (if the timestamp is newer and all...). So if I just update the file itself and don't re-edit the BT server config file, there will be no refresh and no new download of files. Even so the only files which will be downloaded again will be the html docs themselves which are listed as items in the config file which are not my concern here. What I need to refresh (update, download, ...) are other supporting files which I have put in the BT_Docs folder and sent out in the actual app package, and will be used by the nonchanging html docs also included there. I hope I was clear enough... :( I haven't gotten the right answer yet. Hope I do....
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
11/30/12 05:21 AM (13 years ago)
@GoNorthWest: Thanks Mark. I will try to reference the files I need in a URL inside my html doc instead of using their local version, if this is what you meant. I hope I have understood what you meant correctly. Because as I said to Calypso Kid, I don't intend to update the html doc listed as a screen inside Buzztouch itself. I intend to update the supporting files for it. For example a banner which changes weekly due to social calendar, or sales offers, or an xml with pricing details,.... These can't be just addressed on the web. I need to have the latest version possible always residing on the device itself.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
11/30/12 08:51 AM (13 years ago)
If the screen is HTML content, then I think the best buzztouch screen to use is the Custom URL screen, which allows you to link to an HTML file hosted somewhere other than on the app. Then you can change that file as you see fit, and each time the user taps on a menu item to access that screen, the app will download the latest version of everything. It would require a network connection of course. Another possibility, again if this is an HTML screen, is, in the HTML itself, reference URLs for parts of the page you want to be able to change remotely. So, perhaps a banner would be <img src="http://somesite.com/banner.jpg"> instead of <img src="banner.jpg">, which would then allow you to change the banner at will. Mark
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
12/01/12 03:23 AM (13 years ago)
@GoNorthWest as you said in the case of a custom url, I will of course need a connection. So no offline viewing possible! (Oh and if I put my htmls and other related files in the assets folder, how can I address this with a url as a custom url address?) In the case of the HTML Doc though, would referencing web based urls as the src of an image allow the app to cache the image (for offline viewing) or not (I haven't tested, I just don't think it will be cached and if there is no live connection, the image will be missing although the html works as a whole). Correct me if I am wrong.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/01/12 10:23 PM (13 years ago)
Hi @WebNevees, If you reference an HTML doc using a URL, it will be cached the first time that a user requests that screen. That's an important point, though...the user must tap on that screen at least once in order for the content to be downloaded. At that point, it's cached in case the next time it's requested, the user doesn't have a network connection. There is no way to download all URL-based media when the app first opens...it has to be requested by the user. Mark
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.