将ActionDispatch :: Http :: UploadedFile上传到Amazon S3

时间:2013-07-29 02:04:25

标签: ruby-on-rails ruby ruby-on-rails-3 amazon-s3

如何将ActionDispatch::Http::UploadedFile上传到Amazon S3?

@file_data = params[:upload][:file]
s3 = AWS::S3.new
obj = s3.buckets['WeMake'].objects.create("video", file)

然后我得到这个错误:ArgumentError(:数据必须作为字符串,路径名,文件或响应#read和#eof?的对象提供):

1 个答案:

答案 0 :(得分:11)

我需要访问实际文件params[:upload][:file].tempfile并为s3上传添加文件扩展名obj = s3.buckets['Bucket'].objects.create("video.mov", @file_data.tempfile)