[英]using Amazon S3 with the paperclip gem
Is it good practice to simply post my access key id/secret access key directly into the model? 将我的访问密钥ID /秘密访问密钥直接发布到模型中是否是一种好习惯? For example... 例如...
has_attached_file :pic, :s3_credentials => {
:bucket => 'MY_BUCKET_NAME',
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
:url => "/system/:attachment/:id/:style/:filename",
:access_key_id => "12345Secret#blahblah",
:secret_access_key => "12345###"
}
This actually works, however, when I duplicate the image to another model...it doesnt upload. 但是,当我将图像复制到另一个模型时,这实际上是有效的……它没有上传。
ie @other_user.pic = @user.pic
(to copy the image to the other User) 即@other_user.pic = @user.pic
(将图像复制到其他用户)
For instance if the image that works is: S3Amazon/pic/01.working.jpg
例如,如果有效的图像是: S3Amazon/pic/01.working.jpg
the copied image has a one number increase in the file like so: S3Amazon/pic/02.working.jpg
复制的图像在文件中增加了一个数字,如下所示: S3Amazon/pic/02.working.jpg
This image does not open, been searching all week for a way to make this work. 该图片未打开,整周都在寻找实现此效果的方法。
Try 尝试
@other_user.pic = @user.pic
@other_user.save!
And make sure, if you're doing this from the console, that you do @other_user.reload
before checking urls 并确保(如果从控制台执行此@other_user.reload
在检查url之前执行@other_user.reload
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.