1
我正在将新回形针附件上传到AWS S3。但是我需要将文件系统上的很多旧映像迁移到S3。我正在尝试这个耙子任务,但我无法弄清楚我应该如何在S3上提供铲斗路径。将旧回形针图像从文件系统迁移到S3
task :copy_paperclip_data => :environment do
@toycars = ToyCar.find :all
@toycars.each do |toycar|
unless toycar.image_file_name.blank?
filename = Rails.root.join('public', 'system', 'images', toycar.id.to_s, 'original', toycar.image_file_name) # this allows me to change path on filesystem, but i want to make it upload on s3
if File.exists? filename
image = File.new filename
toycar.image = image
toycar.save
image.close
end
end
end
end
你看的AWS s3宝石:http://amazon.rubyforge.org? –
@ArvindMehra嗨,你能告诉我你为什么搬到S3,使用文件系统不是一个好主意吗? – medBo