回形针不会在 Heroku 上创建缩略图
我一直在尝试使用回形针将图像上传到亚马逊 s3,但我得到的只是正在上传的原始文件。不生成缩略图。我的模型中有这样的内容:
has_attached_file :screenshot, :styles => {
:thumb => "100x80>",
:medium => "195x150>",
:large => "390x300>"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension"
原始文件实际上已上传,但没有出现缩略图。例如,如果我复制拇指格式图像的 src,我会得到
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>screenshots/8/thumb.png</Key>
<RequestId>B8A408560070E836</RequestId>
−
<HostId>
HAHUCuNxGKVDvqE3GnhGT1RcBgFGUxa35kqXmyRE+ii60DJS6r22ChDr22cOeCea
</HostId>
</Error>
This is running on heroku,这迫使我使用像亚马逊这样的服务。不是问题,但我能找到的所有文档都使这看起来很简单。我找不到任何依赖项(bundler 很高兴),而且我已经使用 AWS 两年了,没有出现这些问题,在另一个站点上,同一帐户上有不同的存储桶。是不是账号连接桶的问题?我使用与其他站点相同的凭据。只有桶发生变化。
还有一些事情。在正在上传的图像的路径中创建的目录的权限为 000 或任何 aws 等效权限。任何人都不被允许做任何事。
使用 Rails 3。
I've been trying to get paperclip to upload images to amazon s3, but all I get is the original file being uploaded. No thumbnails are generated. My model has this in it:
has_attached_file :screenshot, :styles => {
:thumb => "100x80>",
:medium => "195x150>",
:large => "390x300>"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style.:extension"
The original file is in fact uploaded, but none of thumbnails appear. If I copy the src of a thumb format image, for instance, I get
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>screenshots/8/thumb.png</Key>
<RequestId>B8A408560070E836</RequestId>
−
<HostId>
HAHUCuNxGKVDvqE3GnhGT1RcBgFGUxa35kqXmyRE+ii60DJS6r22ChDr22cOeCea
</HostId>
</Error>
This is running on heroku, which forces me to use a service like amazon. Not a problem but all the documentation I can find makes this look straightforward. I can't find any dependencies (bundler is happy), and I've been using AWS for 2 years now, without these problems, on another site, with a different bucket on the same account. Is it a problem of connecting the bucket to the account? I'm using the same credentials as in the other site. Only the bucket changes.
A couple more things. The directories that are being created in the path of the image that is being uploaded are permissions 000 or whatever the aws equivalent is. Nobody is permitted to do anything.
using Rails 3.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有同样的问题,答案在于:
不要将图像存储在具有不同名称的同一folder_id 中,而是使用相同的图像名称并使用文件夹的样式。上面的内容可以翻译成:
因此,您不必尝试生成类似以下内容:
您会得到以下结果:
I had the same problem and the answer lies in:
Instead of storing the images in the same folder_id with different names, use the same name for the image and use the style for folders. The above would translate into:
So instead of trying to generate something like:
You get this:
我安装了回形针作为插件,一切正常。
不要忘记从 Gemfile 中删除 gem。
I installed paperclip as a plugin, and everything works.
Don't forget to remove the gem from your Gemfile.