~ 9 min read

Using Amazon S3 to Serve JAD Files for BlackBerry OTA Distribution

If you don't want the preamble of why I wanted to serve JAD files from Amazon S3, skip to the second paragraph.

I have recently came across the need to push OTA update of the DailyHoroscope application for BlackBerry. I conjectured that OTA updates have different behavior and thus different impact on the web server. There are still many people using their smartphones in general and BlackBerries in particular over the slower EDGE connections as opposed to 3G, not to mention 4G and/or WiMax. So to download 300K file over EDGE connection in the real usage example can take anywhere between 10 seconds to couple minutes. All this time the webserver's thread serving this specific client will remain running. So it seems like you (or rather your server) can be in a nasty situation when 1000 users simultaneously or almost simultaneously decide to do the OTA update. Also quick calculation with Amazon WS calculator shows that serving files from S3 would be rather cheap even comparing to renting a cheap VPS for that purpose. My estimate was that the whole upgrade process (considering the fact that almost all the users update from S3) will cost me about $15. And this is independent of the time span. For $15 you could get a very cheap VPS for one month (if you are lucky). So it seemed like a no brainer. It indeed was until I faced a few problems with setting this up which I will cover here so that you don't have to spend much time looking for solutions if you want to do the same.

Setting up S3 is a breeze. Using it - not so much. It is just like any other service pretty much - when you want to sign up and call sales you are answered immediately but if you have a problem and need customer service, well, you can be on hold quite a while. If you have Amazon account already set up, you can use this account. You will have the option to opt for the payment to any of the payment options (now it seems that this is only credit cards) already on file with Amazon or you could add a new credit card so that your S3 bill is billed separately.

When you signed up, you are almost ready to begin using S3. Once you receive confirmation email which can take a few minutes until your request is processed and billing information verified, you are set to go.

Now you can use this information to log in to S3 and start uploading files. To access S3 you can use S3Fox from any platform since it is FireFox plugin. You can use CyberDuck if you are on Mac which is an excellent free general purpose FTP client which also supports WebDav and SFTP. If you are on Windows, there is also free and feature rich client CloudBerry. S3Fox is very nice and fast and you do not have to install anything on the system, only plugin for FireFox, but I will be using CloudBerry since we will need to set custom Content-Type for the JAD and COD files and CloudBerry is more feature rich than S3Fox.

Now the whole world can read the files you uploaded. The problem with BlackBerry OTA distribution is that Amazon does not send the right mime-types in the HTML Content-type header. And this is something that you will need to get fixed before people can actually install your application over the air directly from S3.

The right content types for the the JAD and COD are:

So using the custom HTTP headers menu button we will be setting those types for JAD file and all the COD files respectively.

You will get the custom HTTP headers dialog:

Now you can repeat the above step for each COD file individually, or you can select all the COD files and set the headers at once but then you would need to add the "Content-Type" header manually for the right COD mime type - application/vnd.rim.cod. Just use "Add" and in the HTTP-Header enter "Content-Type" and in the Value enter "application/vnd.rim.cod". You should see something like the following dialog

***IMPORTANT to check the "Keep existing headers" or you will loose all your default defined headers which is not good in most cases.

That's it, you are DONE! Check that you did everything right by pointing your BB browser to http://yourUniqueName.s3.amazonaws.com/yourReleaseFolder/AppName.jad and make sure that you can install the application from there. If you did everything right it should work.

Overall S3 seems like a very nice (and apparently very cheap) service and anyone who serves lots of static content should consider using it for that purpose. But not everything seems so pink in the world of S3 and I am sure you will face many other small problems and nuances while setting it up as I did for my task. But hopefully if serving BlackBerry application is all you want, you should now have everything to get you started.