Javascript 上传到AmazonS3
我正在尝试将图片上传到AmazonS3。我成功地使用了carrierwave。然后我切换到jQuery多图像上传。遵循铁路标准383 我的upload_助手看起来完全如图所示;除了初始化方法。 以下是用户可以上传照片的页面:Javascript 上传到AmazonS3,javascript,ruby-on-rails,amazon-s3,Javascript,Ruby On Rails,Amazon S3,我正在尝试将图片上传到AmazonS3。我成功地使用了carrierwave。然后我切换到jQuery多图像上传。遵循铁路标准383 我的upload_助手看起来完全如图所示;除了初始化方法。 以下是用户可以上传照片的页面: = s3_uploader_form post: items_url, as: "painting[image_url]" do = file_field_tag :file, multiple: true %script#templat
= s3_uploader_form post: items_url, as: "painting[image_url]" do
= file_field_tag :file, multiple: true
%script#template-upload{type: "text/x-tmpl"}
.upload
{%=o.name%}
.progress
.bar{ style: "width: 0%" }
我也有以下几点:
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require paintings
正如教程中所示
尽管我的S3上传与carrierwave和单文件上传配合得很好,但我得到了
failed to upload image error (coming from the last line in paintings.js.coffee). and
Failed to load resource: the server responded with a status of 400 (Bad Request)
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>XYZ</RequestId>
<HostId>
XYZ
</HostId>
</Error>
我的CORS配置是:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>http://localhost:3000</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
http://localhost:3000
得到
邮递
3000
*
非常感谢您的指导找到了
在upload\u helper>S3Uploader>Initialize中,向“到期日”添加时区,如下所示:
expiration: 10.hours.from_now.utc,
这对我来说太神奇了
祝你好运