[英]Rails 3 & Paperclip - Can I store images both on S3 & locally?
We have a situation where we would like to start hosting images on Amazon's S3 service, however we don't want to upload all of our existing images to S3, instead we want to serve these "legacy" images from where they are hosted at the moment & going forward upload all new images to S3 and obviously serve those from S3. 在某些情况下,我们想开始在Amazon的S3服务上托管映像,但是我们不想将所有现有映像上传到S3,而是希望从托管它们的位置提供这些“旧”映像。现在和将来,将所有新图像上传到S3,显然可以为S3提供这些图像。
Does anyone know if this is possible using either PaperClip or CarrierWave? 有谁知道使用PaperClip或CarrierWave是否可行?
Thanks! 谢谢!
Here how you do this if you don't have a any version create a version called :s3_version
(anything you like) 如果您没有任何版本,请按以下步骤进行操作:创建一个名为
:s3_version
的版本(任何您喜欢的版本)
something like this 像这样的东西
class YourUploader < CarrierWave::Base
storage :file
version :s3_version do
storage :fog
## As far as I know it would save the file with appending 's3_version_(your_file_name)
def full_filename(for_file)
super.gsub(/s3_version_/,"")
end
def filename
self.to_s.gsub(/s3_version_/,'')
end
end
I think this would do all you want storing the file
both locally as well as on S3
. 我认为这将完成您想要在本地以及在
S3
上存储file
所有操作。
I haven't tested this with multiple version
but I guess it can too be done with :from
clause I believe 但我想也可以用
:from
子句来完成
Something like this 像这样
version :thumb do
process resize_to_fill: [280, 280]
end
version :s3_thumb, :from_version => :thumb do
storage :s3
end
haven't tested it though 还没有测试
Hope this help 希望这个帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.