我正在使用Paperclip,我想在S3上为用户的头像上传图片。
我的CSV
username avatar_url
foo https://s3.amazonaws.com/foo/seed/10215716104_e09765dabd_z.jpg
我打算follow this tutorial创建一个CSV,以及此SO question(用于Paperclip播种),所以像这样:
require 'csv'
csv_text = File.read(Rails.root.join('lib', 'seeds', 'user.csv'))
csv = CSV.parse(csv_text, :headers => true, :encoding => 'ISO-8859-1')
csv.each do |row|
u = User.new
u.username = row['username']
u.avatar = File.open(row['avatar_url'])
u.save
end
然而,当我在控制台中尝试这个时,就像这样:
User.create(username: 'foo', avatar: File.new("https://s3.amazonaws.com/foo/seed/10215716104_e09765dab"))
我收到错误:
Errno::ENOENT: No such file or directory @ rb_sysopen - https://s3.amazonaws.com/foo/seed/10215716104_e09765dabd_z.jpg
是否可以在S3上播种图像?
答案 0 :(得分:0)
以下是我如何使用它:
Entered the Search Function
Left the Search Function
Getting Searches
BS Implemented
Inside the try function
PAss 1
Pass 2