Wednesday, November 24, 2010

Downloading EXE files from S3

It is more than a little frustrating that Internet Explorer and Windows cannot do anything to match what the other major browsers and operating systems are doing, or so it seems.  Internet Explorer has long been the browser that most developers hate to support.  Today, I ran across something that wasn't HTML or CSS related but still caused issues on Windows using Internet Explorer.
As many of you know, I use Amazon Web Services to do much of my work and S3, Simple Storage Service, is a large part of what I work with.  Today, I was made aware that someone could not download an EXE file from S3 onto their desktop.  I tested it out, and it was fine for me.  Classic developer response right? Turns out, it worked for me because I was using Chrome on my Mac.  It didn't work quite right in Internet Explorer on Windows.  The file would download, but it would not bring down the extension to the file.  What I mean, is if the file was stored in S3 as "filename.exe", when it was downloaded to the Windows machine it would only be named "filename".   I was encouraged by some people that I know to simply chalk it up to a security concern, and while I do not encourage anyone downloading random .exe files and installing them, I knew that this just couldn't be the case.  As it turns out, Internet Explorer must be told the Content-Disposition of the file when it is an EXE or DLL.  This is done in the headers when the file is requested.  Luckily, S3 allows you to put metadata on a file that is passed down when the file is requested.  To allow Internet Explorer to recognize and save the file with the .exe extension you will just need to add the Content-Disposition:attachment; filename=<filename.exe> header.




You can do this as metadata in S3 through the AWS console.  Many of the software utilities that work with S3 also allow you to set this metadata programmatically when storing the objects.
I am used to all sorts of JavaScript, HTML, CSS problems when working with IE, but this one really threw me for a loop at first.  I hope that this helps you.

4 comments:

Anthony said...

Cheers heaps for this! threw me off for ages too...

Unknown said...

Anthony, I am glad that it was helpful. Thanks for stopping by

Anonymous said...

Thanks, this saved me from pulling out my hair!

Vale Co Xenia said...


IEEE Projects on Cloud Computing



JavaScript Training in Chennai


Final Year Projects for CSE



JavaScript Training in Chennai