Tuesday, 15 September 2015

ruby on rails 3 - trouble setting content-type on amazon s3 with carrierwave direct -


I have a rail app, which successfully uploads S3 with the use of carrier wah and fog after the railwaycast tutorial is. Now I am trying to use the CarrierWorld Direct gem to upload the file directly to S3. It was set in the form of binary / octet-stream, except for the type of content, allowing images to download files in the browser rather than displaying the JPG.

So according to the Gem instructions, I added the configuration for the carrier:

  config.will_include_content_type = true   

and a hidden Added added field content-type image / with the value of JPEG

The file upload form generated by the Form Assistant looks correct:

  & lt; Form accept-charset = "UTF-8" action = "https://mybucket.s3.amazonaws.com/" class = "new_product_image_uploader" enctype = "multipart / form-data" id = "new_product_image_uploader" method = "post" & Gt; & Lt; Div style = "margin: 0; padding: 0; display: inline" & gt; Input name = "UTF8" type = "hidden" value = "one" ??? "& Gt; & lt; / div & gt; & lt; input id =" product_image_uploader_key "name =" key "type =" hidden "value =" upload /.../$ {filename} "& gt; Lt; Input id = "product_image_uploader_aws_access_key_id" name = "AWSAccessKeyId" type = "hidden" value = "..." & gt; & lt; input id = "product_image_uploader_acl" name = "ACL" type = "hidden" value = "Public-read" & gt; Input id = "product_image_uploader_success_action_redirect" name = "success_action_redirect" type = "hidden" value = "http: // localhost: 5000 / product" & gt; & lt; input id = "Product_image_uploader_policy" name = "policy" type = "hidden" value = ".. . "& Gt; Input id =" product_image_uploader_signature "name =" signature "type =" hidden "value =" ... "& gt; & lt; input id =" product_image_uploader_product_image "name =" file "type = "File">  



< ; Input name = "commit" type = "submit" value = "create product image uploader" & gt; & Lt; / Form & gt;

The base 64 encoded policy is:

  {"end": "2013-06-21T13: 35: 42Z", "Terms": [ , "Starting with", "$ UTF8", "starting with", ""], ["start-up", "$ key", "upload"], ["start-up", "$ content type" {"Bucket": "mybucket"}, {"ACL": "public reading"}, {"success_action_redirect": "http: // localhost: 5000 / products"}, ["content-length distance", which Appears here with this article:  

But when I check it locally, I get this error response in the browser P>

  & lt; Error & gt; & Lt; Code & gt; Accessed & lt; / Code & gt; & Lt; Message & gt; Invalid in accordance with policy: Policy condition failed: ["Start-up", "$ Content-type", ""] & lt; / Message & gt; ... & lt; / Error & gt;   

I do not really know what that means. I googled for this error and found this issue:

But the solution is not useful, am I missing something?

I am using:

Carrier marriage (0.8.0) activium (> = 3.2.0) activesupport (& gt; = 3.2.0) Carrier marriage_day (0.0 .12)

Rail (3.2.13)

Googling around something After more, I found the following comments on this page:

    

File input field Change content-type hidden input fields before fixing my problem.

No comments:

Post a Comment