Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
kr33
Posts: 4
Registered: ‎03-28-2011
My Device: Curve 8520

How to download files from server folder/path

Hi All,

 

I'm busy writing an application for the Blackberry 8520 curve for work. The application will be required to download a data file before use from one of our servers.

 

How would I go about doing this, not sure where to even start.

 

Any help will be extremely appreciated.:Helpsmilie:

Developer
indusBULL
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Re: How to download files from server folder/path

 

what is file format that u will get from server?

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to download files from server folder/path

Most web servers will actually supply you the data in any file in any directory that they know about, provided you specify the correct URL.  So if the Web Server is running directory myWebServer/baseDirectory on the Server machine, and has a text file in a directory called

directory myWebServer/baseDirectory/MyTextFiles/a.txt

Then you can do an http GET for the URL

www.myserver.com/myMyTextFiles/a.txt

where www.myserver.com directs the request to your Web Server,

and you will get the txt file.

 

So all you need at its most basic is standard http GET and knowing the location of the file. 

 

The httpDemo code will do this for you.

 

Things start getting a little more confusing when you want to download non text files, but we can cross that Bridge when you get to it.

New Contributor
kr33
Posts: 4
Registered: ‎03-28-2011
My Device: Curve 8520

Re: How to download files from server folder/path

i want to download a xml file. This file will contain the relevant data the application needs, depending on the config selections in the app itself.

New Contributor
kr33
Posts: 4
Registered: ‎03-28-2011
My Device: Curve 8520

Re: How to download files from server folder/path

Thanks peter,

 

Makes sense, however, does what you say apply to a web app or standalone blackberry application. My application is a standalone application installed on the device itself.

 

Would the procedure be the same? Keeping in mind that the download needs to be completely automated and in the background....the user just needs to set the parameter in the app, and the app will do the rest before the user starts using the app. This will be a once off download until the parameter used is changed again.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to download files from server folder/path

I was talking about a standalone java apps. 

 

There is an issue with getting data like this before the app starts up,  So you need to code your app so that it goes into a known state (say displaying a useful "Please wait while I download my config" screen) until the config is actually downloaded.  So I'm not sure you want to download in the background. 

 

But the basic download process is quite straightforward - as I suggested, httpDemo does it, a does the 'GET' processing in the sample:here:

http://supportforums.blackberry.com/t5/Java-Development/Sample-HTTP-Connection-code-and-BIS-B-Access...

 

I think it would be useful for you to review both these examples, I think they will fill in some of the gaps in your knowledge and will help you decide how you want to implement this process.