我们正在使用Paperclip,我们决定通过让Paperclip在每个图像进入jpeg时节省空间:
has_attached_file :image, styles: { original: ["2048x2048>", :jpg], medium: "300x300>", thumb: "100x100>" }
问题是现在所有的URL都已更改为.jpg
而没有重新处理图像:
https://s3.amazonaws.com/cambeo-paperclip-production/task_images/images/000/000/086/original/MyGroovyShoes.jpg?1528122839
精细。所以让我们重新处理图像:
t.image.reprocess!
[paperclip] Trying to link /tmp/241d38ce8789f0210d55f5967aba05d920180604-32561-1t4fue1.png to /tmp/241d38ce8789f0210d55f5967aba05d920180604-32561-1tp6vu.png
Command :: file -b --mime '/tmp/241d38ce8789f0210d55f5967aba05d920180604-32561-1tp6vu.png'
[paperclip] Content Type Spoof: Filename MyGroovyShoes.png (image/png from Headers, ["image/png"] from Extension), content type discovered from file command: inode/x-empty. See documentation to allow this combination.
[paperclip] saving /task_images/images/000/000/086/original/MyGroovyShoes.jpg
[Aws::S3::Client 200 0.014972 0 retries] put_object(content_type:"image/png",acl:"public-read",bucket:"cambeo-paperclip-production",key:"task_images/images/000/000/086/original/MyGroovyShoes.jpg",body:#<File:/tmp/241d38ce8789f0210d55f5967aba05d920180604-32561-1t4fue1.png (0 bytes)>)
因此,这看起来像内容欺骗问题,因为我们现在调用原始jpg
文件,这是png
我已经检查了wiki,如果你更改orignial
造型