Friday, January 29, 2010

Flash player upload issues on Mac

The upload page on shwup used to be powered by Aurigma, a Java based tool that allows for multiple file selections and some other funky technical stuff. Since our last February release, we replaced this by our own custom uploader, written in Flash.

From Flash player 8 onwards, file uploads are natively supported (albeit with some quirks regarding cookie passing in browsers other than IE and nasty security fixes from version 10 onwards). Together with the ExternalInterface, building a more powerful uploader tool was within our grasp.

Within the first few weeks of deployment we received some feedback, predominantly from the Mac users, that the uploader simply wasn't working for them. Having no other means to upload files to shwup (other than via email) this was very painful for those users.

So we went ahead with eliminating the differences:
  1. use the same browser
  2. use the same Flash player
This didn't pinpoint a particular client side issue that could be held responsible. However, performing the same tests on our test and staging environment didn't exhibit the same issue; it actually worked!

Turning to the live server configuration it slowly became apparent that this problem was double sided; the combination of client platform and server configuration was causing some issue.

To make sure our user's address bar always contains "www.shwup.com" when visiting our website we use mod_rewrite to redirect any requests without the proper address using the following rule:

RewriteCond %{HTTP_HOST} !^www\.shwup\.com$ [NC]
RewriteRule ^(.*)$ http://www.shwup.com$1 [R=301,QSA,L]

We thought that this couldn't possibly cause an issue until we switched on the debug option; it became clear that Flash player was passing "www.shwup.com:80" as the HTTP Host header; obviously this breaks the above regular expression and causes a redirect after which the Flash player happily reports that the upload was done without issues. Funny enough, this only happens on the Mac. Some developers have already reported this issue on Adobe's file upload article.

The following rule change fixed the issue:

RewriteCond %{HTTP_HOST} !^www\.shwup\.com(:\d+)?$ [NC]
RewriteRule ^(.*)$ http://www.shwup.com$1 [R=301,QSA,L]

After spending this much time we can only say "assume nothing" when it comes to cross platform coding.

Source: http://shwup.blogspot.com/2009/04/flash-player-upload-issues-on-mac.html

No comments:

Post a Comment