users@glassfish.java.net

Re: Content-Disposition ignored by mobile devices.

From: <glassfish_at_javadesktop.org>
Date: Thu, 25 Oct 2007 10:34:33 PDT

Hi,
I don't think this has anything to do with GF - and I cannot offer you any GF specific solution to the problem. However, I had exactly the same problem in the past, so at least I can give you some useful pointers.

Some time ago I wrote (in php) an application providing secure file storage. Obviously, to be considered secure, the files should not be placed in the web root and be accessible by name, so I ended up with a URL similar to

somethig.com/download.php?id=1234

The download.php script checked your session to see if you had enough permissions, then set the header with the filename and started streaming the file. Everything was wondering wonderfully, untill my boss asked me to rewrite the page to provide easy access to mobile devices.... easy task I thought, until I found out that mobile devices completely ignore the filename in the header, so I got a "save as.." requester prefilled with "download.php" as filename (and, being the device a M$ device, having the wrong extension was creating loads of problems)!

I took a week of work, at the end I used a plugin for iis called "url rewrite" (this is a trick I know to work with apache as well, and hopefully something similar can be done in GF).

Basically the trick is to use regular expressions to rewrite the url request sent by the client to the server (this is done server side with something like a filter before the web server receives it), in my case:

somethig.com/downloads/desiredfilename.extension?id=1234

was rewritten and sent to the server as:

somethig.com/download.php?id=1234

This way the mobile device is fooled into thinking the filename is desiredfilename.extension, avoiding the problem with the file header being ignored.

I hope you find this thing useful!

PS: also, you could try to send to the client the right mime type, in most of the cases this is enough to override the extensio and enable the correct application to be launched for streaming on the client.

Piero
[Message sent by forum member 'thedayofcondor' (thedayofcondor)]

http://forums.java.net/jive/thread.jspa?messageID=242186