Writing file to bucket fails on Elastic Beanstalk application

I am writing an application in Ruby on Elastic Beanstalk in which I download a file from a remote server and write it to an object in a bucket.

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

The last line, however, fails with the following exception in the log:

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

I know, however, from executing the same #open on my machine, that f is a StringIO object, which does have #read and #eof?.

Answers


I was getting same error during zip file upload on S3 and finally this worked for me:

zip_data = File.read(zip_file_path)

means, zip_data will be the object at the zip file path that is located in your tmp directory.

Hope, this will work for you also.


Need Your Help

Where are the PHP5 session files temporarily stored using Ubuntu 14.04?

session ubuntu-14.04 php-5.5

Where are the PHP5 session files temporarily stored using Ubuntu 14.04?