Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Patches for iframe-based uploads to Amazon S3 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

evansd
Copy link

@evansd evansd commented Apr 15, 2011

Hi, I've been using your iframe-based uploader to send files to Amazon S3 direct from the browser and I've had to make a couple of small patches.

The first was to move the file input to the end of the form so that the file is the last field submitted: Amazon insist on this as they want to process your credentials and object parameters before they start processing your file data.

The second was to work around cross-domain iframe errors. If the upload is successful Amazon redirect the browser to a URL of your choosing so everything works fine. If the upload fails, however, Amazon don't redirect and so the iframe onLoad code throws a permission denied error when trying to read the iframe properties. I've wrapped this in a try ... catch and just create an empty file.response object if there's an error. You might have a better suggestion for how to handle this condition, but I think it's preferable to catch the error and let the calling code deal with it than to let it propagate.

Thanks for the awesome library!

David Evans added 2 commits April 15, 2011 11:31
When POSTing to Amazon S3, we're required to have the file as the
last field in the form; presumably so Amazon can check your
authorization fields before deciding whether to process the rest of
your request, which could be GB in size.
In some circumstances (e.g, uploading files directly to Amazon S3)
we need to POST to another domain and can't guarantee we'll get
redirected back at the end of the request. In this case, it's
better to create an empty response object and let the calling code
decide how to handle it, rather than throwing a "permission denied"
error.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant