简体   繁体   English

如何在Amazon S3回形针中复制文件?

[英]How to copy file in amazon s3 Paperclip?

I have a model Shop which has a logo and it's stored in amazon s3, i want to copy it to another model Company , i'm doing simply: 我有一个带有logo的模型Shop ,它存储在Amazon s3中,我想将其复制到另一个模型Company ,我在做简单的事情:

shop = Shop.find(1)
company = Company.find(1)
company.logo = shop.logo
company.save!

but its giving an error: 但它给出了一个错误:

[paperclip] copying logos/1/original/220px-Bart_Simpson.png to local file /tmp/dac9e3329951078b23c5deed39f3193120160107-30855-ivrdms.png
No Such Key - cannot copy logos/1/original/220px-Bart_Simpson.png to local file /tmp/dac9e3329951078b23c5deed39f3193120160107-30855-ivrdms.png
Command :: file -b --mime '/tmp/dac9e3329951078b23c5deed39f3193120160107-30855-nz0h5c.png'
[paperclip] Content Type Spoof: Filename 220px-Bart_Simpson.png (["image/png"]), content type discovered from file command: inode/x-empty. See documentation to allow this combination.

ROLLBACK
ActiveRecord::RecordInvalid: Validation failed: Logo has an extension that does not match its contents

Can somebody say what the hell is going on here, or how to do it? 有人可以说这到底是怎么回事吗?

Can you try as, May I know which version of paperclip is being used. 您能尝试一下吗,请问我知道正在使用哪个版本的回形针。

shop = Shop.find(1)
company = Company.find(1)
company.logo = File.open(shop.logo.path, 'rb')
company.save!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM