ruby-on-rails – 剪纸可以从S3桶中读取照片几何吗?
发布时间:2020-12-16 19:58:04 所属栏目:百科 来源:网络整理
导读:我想从我的S3容器中读取照片的几何图形. 当它在我的地方,这工作: def photo_geometry(style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file photo.path(style)end 但是当我将模型切换到S3时,似乎不起作用.任何建议?
我想从我的S3容器中读取照片的几何图形.
当它在我的地方,这工作: def photo_geometry(style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file photo.path(style) end 但是当我将模型切换到S3时,似乎不起作用.任何建议? 更大的故事是,我正在尝试编写一些代码,让我从S3中检索照片,允许用户裁剪它们,然后将其重新上传到仍然由paperclip分配的S3. 编辑: 这是返回的错误: Paperclip::NotIdentifiedByImageMagickError: photos/199/orig/greatReads.png is not recognized by the 'identify' command. from /Users/daniellevine/Sites/hq_channel/vendor/gems/thoughtbot-paperclip-2.3.1/lib/paperclip/geometry.rb:24:in `from_file' from /Users/daniellevine/Sites/hq_channel/app/models/photo.rb:68:in `photo_geometry' from (irb):1 解决方法
如果您使用S3作为存储机制,则不能使用上述的几何方法(它假定为本地文件). PaperClip可以使用Paperclip :: Geometry.from_file将S3文件转换为本地TempFile:
这是我更新的代码: def photo_geometry(style = :original) @geometry ||= {} @geometry[style] ||= Paperclip::Geometry.from_file(photo.to_file(style)) end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |