从本地回形针存储S3迁移 [英] Migrating from local paperclip storage to S3
问题描述
最近,我们搬到一个新的虚拟主机提供商,提供有限的存储空间,所以我们正在努力将所有我们通过回形针宝石到Amazon S3上传用户上传(头像,文件等)。我有几百个文件都对应不同的模式,我现在想迁移集体。
We've recently moved to a new webhost that offers limited storage space so we're trying to move all of our user uploads (Avatars, Files, etc.) uploaded via the Paperclip gem to Amazon S3. I have several hundred files all corresponding to different models that I'm now trying to migrate en masse.
我发现本文,介绍了一个漂亮的回形针rake任务:
I found this document that introduces a nifty paperclip rake task:
耙回形针:刷新:missing_styles
此命令做了一些对我的工作,但是,我发现这只是建立文件结构不发送任何数据 - 除了它不设置使用定义的任何缩略图:风格
散在 has_attached_file
通话。也就是说,我有以下回形针安装在我的车型之一:
This command does some of the work for me, however, I noticed it's only setting up the files structure without sending any data - in addition it's not setting up any thumbnails defined using the :styles
hash in the has_attached_file
call. I.e., I have the following paperclip setup on one of my models:
class User < ActiveRecord::Base
has_attached_file :avatar,
:styles => {
:thumb => "100x100#",
:small => "150x150>",
:medium => "200x200" }
end
下面是一些示例输出运行命令后:
Here's some sample output after running the command:
$ rake paperclip:refresh:missing_styles
Regenerating User -> avatar -> [thumb, :small, :medium]
Regenerating Mercury::Image -> image -> [:medium, :thumb]
Regenerating Profile -> image -> [:home_feature, :large, :medium, :thumb]
Regenerating Page -> preview -> [:portfolio]
Regenerating Category -> default_image -> [:home_feature, :large, :medium, :thumb]
导航到我的S3存储我可以看到所有的目录都被正确安装,并为每个连接,但只适用于原始图像文件,它们都是0字节。我误解这个命令的用法?我找不到任何其他工具来上传批量文件的整个目录到S3,如果有一个安全的工具,在那里,然后我打开耳朵已经涵盖了这无需付款。我试着建立一个Ruby脚本插入到自己的SDK和手动上传这些文件,但它们的Ruby文档也不是很大。
Navigating to my S3 Bucket I can see all the directories are correctly setup and for each attachment, but only for original image files and they're all 0 bytes. Am I misunderstanding the usage of this command? I couldn't find any other tool for uploading entire directories of files in bulk to S3, if there's a safe tool out there that already covers this without requiring payment then I'm open ears. I've tried building a ruby script to plug into their SDK and upload these files manually, but their Ruby documentation isn't great.
推荐答案
看起来像我需要超越的红宝石就这一个, s3cmd 似乎是对这种作业的最合适的工具。在我的例子中,同步
命令的伎俩:
Looks like I needed to go beyond ruby on this one, s3cmd seemed to be the most appropriate tool for this sort of job. In my case, the sync
command did the trick:
s3cmd sync my-app/public/system/ s3://mybucket
这篇关于从本地回形针存储S3迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!