Skip to content

Instantly share code, notes, and snippets.

@tsabat
Last active December 15, 2015 01:49
Show Gist options
  • Save tsabat/5183143 to your computer and use it in GitHub Desktop.
Save tsabat/5183143 to your computer and use it in GitHub Desktop.

We're using CORS to upload files to s3. IE seems to handle this poorly.

###The happy path

  • GET to our servers to sign the S3 upload fields
    • sign the request so amazon will accept it
    • set a redirect property of the form fields
  • POST the form to s3
    • AWS sets a 303 redirect to our predefiend url
  • GET to our servers from the 303
    • The path for this get is set in the step above

Chrome, FireFox and Safari handle the last part, the 303 redirect, properly. However, IE sets the a Content-Type header on a GET request, as shown below.

Key	Value
Content-Type	multipart/form-data; boundary=---------------------------7dd3312270158

This causes rails to bug out, because rack tries to read to the end of the boundary, but finds none:

Started GET "/static/signed/asset/tsabat/83ee6840-7158-0130-c19b-28cfe912f6ff?bucket=s.cdpn.io&key=5%2Fauthor-tim_2.jpg&etag=%2260fb3876d516553ff6f3a018066b3250%22" for 127.0.0.1 at
 2013-03-17 10:46:36 -0700

EOFError - bad content body:
  (gem) rack-1.4.5/lib/rack/multipart/parser.rb:74:in `block in Rack::Multipart::Parser#fast_forward_to_first_boundary'  (gem) rack-1.4.5/lib/rack/multipart/parser.rb:72:in `Rack::Multipart::Parser#fast_forward_to_first_boundary'
  (gem) rack-1.4.5/lib/rack/multipart/parser.rb:72:in `Rack::Multipart::Parser#parse'
  (gem) rack-1.4.5/lib/rack/multipart/parser.rb:15:in `Rack::Multipart.parse_multipart'
  (gem) rack-1.4.5/lib/rack/multipart.rb:25:in `ActionDispatch::Request#parse_multipart'
  (gem) rack-1.4.5/lib/rack/request.rb:336:in `ActionDispatch::Request#POST'
  (gem) rack-1.4.5/lib/rack/request.rb:201:in `ActionDispatch::Request#POST'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment