在Elastic Beanstalk应用程序上将文件写入存储桶失败

时间:2013-06-05 11:55:21

标签: ruby amazon-web-services amazon-s3

我正在Ruby上使用Elastic Beanstalk编写一个应用程序,我从远程服务器下载文件并将其写入存储桶中的对象。

require 'open-uri'
...
s3 = AWS::S3.new
bucket = s3.buckets['mybucket']
f = open(params[:url]) #using open-uri
obj = bucket.objects[params[:key]]
obj.write[f] #<< fails here

然而,最后一行在日志中失败并出现以下异常:

:data must be provided as a String, Pathname, File, or an object that responds to #read and #eof?

但是,我知道,在我的计算机上执行相同的#open时,f是一个StringIO对象,其中包含#read#eof?

1 个答案:

答案 0 :(得分:0)

我在S3上传zip文件时遇到同样的错误,最后这对我有用:

zip_data = File.read(zip_file_path)

表示,zip_data将是位于tmp目录中的zip文件路径的对象。

希望,这对你也有用。

相关问题