[英]Rails uploading to Amazon S3 bucket
I have two differnt buckets in the same Amazon S3 account. 我在同一Amazon S3帐户中有两个不同的存储桶。 I can upload fine to one but not the other.
我可以上载一个,但不能上载。
pictures.rb pictures.rb
def self.set_s3_direct_post
return S3_BUCKET.presigned_post(key: "uploads/#{SecureRandom.uuid}/${filename}", success_action_status: '201', acl: 'public-read')
end
aws.rb aws.rb
S3_BUCKET = Aws::S3::Resource.new.bucket(ENV['S3_FIRST_BUCKET'])
Trying to change bucket (with S3_SECOND_BUCKET
instead of S3_FIRST_BUCKET
) results in a failed upload. 尝试更改存储桶(使用
S3_SECOND_BUCKET
而不是S3_FIRST_BUCKET
)会导致上传失败。 I notice that the url for a failed upload is in the form: 我注意到上传失败的网址的格式如下:
https://s3.amazonaws.com/%E2%80%9Csecond_bucket%E2%80%9D
but a successful upload looks like: 但是成功上传看起来像:
https://first_bucket.s3.amazonaws.com
How do I control this?? 我该如何控制?
Unbelievable. 难以置信的。 I edited my ~/.profile file in TextEdit.
我在TextEdit中编辑了〜/ .profile文件。 The addition of the line:
增加的行:
export S3_SECOND_BUCKET="second_bucket"
put slightly curly double-quotes around second_bucket
. 在
second_bucket
周围使用略微卷曲的双引号。 Turns out these double-quotes are different to the ones Sublime Text 2 uses, which are straight (like above). 事实证明,这些双引号与Sublime Text 2所使用的引号是直的(如上)不同。 The TextEdit versions weren't being recognised as quotes.
无法将TextEdit版本识别为引号。 Cheers TextEdit, you t**t.
干杯TextEdit,您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.