Rails 3&回形针-我可以同时在S3和A3上存储图像吗?当地的? [英] Rails 3 & Paperclip - Can I store images both on S3 & locally?
问题描述
在某些情况下,我们想开始在Amazon的S3服务上托管图像,但是我们不希望将所有现有图像上传到S3,而是希望从这些图像的原始位置提供这些旧图像目前&
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.
有人知道是否可以使用PaperClip或CarrierWave做到这一点?
Does anyone know if this is possible using either PaperClip or CarrierWave?
谢谢!
推荐答案
如果没有创建任何版本,请按以下步骤进行操作名为:s3_version
(任何您喜欢的版本)
Here how you do this if you don't have a any version create a version called :s3_version
(anything you like)
类似这样的版本
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
我想这将满足您在本地以及 S3
上存储文件
的所有需求。 / p>
警告:
I think this would do all you want storing the file
both locally as well as on S3
.
I haven't tested this with multiple version
但是我想也可以使用:from
子句来完成
but I guess it can too be done with :from
clause I believe
类似这样的东西
version :thumb do
process resize_to_fill: [280, 280]
end
version :s3_thumb, :from_version => :thumb do
storage :s3
end
虽然没有测试
希望获得帮助
这篇关于Rails 3&回形针-我可以同时在S3和A3上存储图像吗?当地的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!