Sigh, we're back to this. I can easily enough use CORS on any decent enough browser to directly upload files to my AWS S3 bucket. But (it was coming), with IE I have to fall back to Iframes. Easy, set up a hidden Iframe, create a form, set its target to Iframe name/id, submit form. If the upload is successful, the Iframe is redirected to a url I specify and I can access the whatever I need to. But if an error occurs, since the Iframe is now on an AWS domain, I won't have access to the XML content of the error. Infact, I won't even know that an error has occurred.
I've seen brave people on the internet talking about hosting an html file, on the same bucket to which files are to be uploaded, and then using postMessages to route the Iframe content, or something of that sort.
Could someone please explain to me how to achieve this mythical solution? The jQuery file uploader by Blueimp seems to solve this, but by God the code is so jQueryified that I haven't been able to get the gist of it.
Editing for clarity
- IE<10 does not have a FileReader API.
- Because of 1, I cannot use an XDomainRequest to send a file to S3
- So use an Iframe and post that along with a complete form to S3
- If successful, AWS redirects to a page on server, which reads the headers and
then returns a JSONP style response that can be read by scripts on client (redirect page can
be specified by me). - If on error, all I can do right now is wait for a timeout to expire and then console log
an IFRAME ID, and popup an alert so that the user can then query for the the iframe by ID,
read the DAMN XML content, figure out the AWS specified error, and then retry (I'm being sarcastic..)