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 Developer
Posts: 33
Registered: ‎08-04-2010
My Device: Not Specified

Adding Extra Resources to Server and Downloading to Device

We have a multimedia application with over 150 pictures and around 15 video clips (Around 1 minute in length). I know this is too much to embed within the application itself. I think the right way to do this is to add the files to a server and have the application access these resources over the internet. But I'm not too sure what the best way is to do this.

 

Our client said they can put the files on their server, but I just need to tell them if there is a specific way it needs to be done. I have never worked with a server so my knowledge of how you would do this is extremely limited. Will they need to create a new page/url for each resource file? From my research, that appears to be the case, but I have tons of resources. Is there an easier way to tackle this? I'm assuming all I need to do the application is the separate urls, right? Thanks for any information you can provide.

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

If it is anything sensitive, I would suggest having some sort of script/app on the server that will serve up the files you request. Actually it might make it a lot simpler for you to just have a base url, say: http://www.yourserver.com/get_file.php?file=FILENAME (or something similar) in case you want to move stuff around on the server you won't have to update your application to reflect the changes.

New Developer
Posts: 33
Registered: ‎08-04-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

Thanks for the reply. They do have their own domain/base url, as this is a webserver they use to host their website. They do not want to put these resources on the website itself. So if I understand you correctly, all I need to tell my client to do is to 1) upload all the files to the server 2) write a script on the server for searching for the files 3) give me the url to the script. Is that right? Then on my application side, all I need to do to access image001.jpg is reference "http//www.server.com/script.php?file=image001.jpg". I apologize if this seems elementery, but I simply don't know anything about this. And just to verify, that means they do not need to make a separate page or anything for each resource, right?  Thanks again.

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

Yep sounds like you've got it! And you are correct, doing this they can just give you the one URL and you can request the files from that instead of from multiple URLs, all you have to do is change the file= argument.

New Developer
Posts: 33
Registered: ‎08-04-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

Do you know of a good example script I can give the client in case they need help? Or a good place to look for information on how to do this? I'm not sure how much they know about scripting or php. Thanks again.

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

I think the most important one will be the header() call in PHP http://us3.php.net/manual/en/function.header.php (if you go with PHP that is). There are a lot of good user comments on there that should help in development.

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

Re: Adding Extra Resources to Server and Downloading to Device

If you want to do this 'cheap and cheerful' and/or quickly, you don't implement a a script.  Instead just get a URL that represents a directory on the Web Server and download your files directly from there. 

 

So say their server is called

www.theircompnay.com/BB/download/

 

and the file is called

picture1.jpg

 

then you can use code like this:

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

 

to download from

http://www.theircompnay.com/BB/download/picture1.jpg

 

I suspect that you will have files that are quite big - to make sure these a re-startable in chunks, you might want to consider this code:

 

http://supportforums.blackberry.com/t5/Java-Development/HTTP-413-Request-Entity-Too-Large/ta-p/44598...

 

Hope this helps.

New Developer
Posts: 33
Registered: ‎08-04-2010
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

So what your saying, I don't even need to make an extra file (html or script). Rather simply add the files to a directory? I was thinking that they needed to be on a page or something.

 

Assuming their server is "www.company.com". I can: 

1) Create a new directory called "Pictures"

2) Add all pictures to that folder

3) In my application, if I want to access image001.jpg, all I have to do is reference "www.company.com/Pictures/image001.jpg

 

That would be the perfect scenario, but for some reason I was thinking there was going to be more to it than just uploading the files to the server. Did I understand that correctly?

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Adding Extra Resources to Server and Downloading to Device

What you are suggesting should work fine. 

 

There are advantages to using a script, most notably:

a) The file location and name can change without you needing to change the BB - you just change the script

b) You might have some security restrictions so want to authenticate the download.