The main problem is that you have version 2 of the AWS SDK for Ruby installed, but you are referring to the documentation for version 1 . Version 2 documentation can be found here:
http://docs.aws.amazon.com/sdkforruby/api/index.html
To update your example to use version 2:
s3 = Aws::S3::Resource.new bucket = s3.bucket(BUCKET_NAME) begin bucket.object(KEY).upload_file(FILENAME) puts "Uploading file #{FILE_NAME} to bucket #{BUCKET_NAME}." bucket.objects.each do |obj| puts "#{obj.key} => #{obj.etag}" end rescue Aws::S3::Errors::ServiceError
The main differences:
- Version 1 used the # [] method in the collection to refer to an object by its key. Version 2 has two methods:
#objects() and #object(key) . The last is getter. The first lists all the objects in the bucket. - Version 2 has a specialized method
#upload_file , which controls the loading of an object from disk. This is similar to #write from version 1, but can also use multiple threads to load large objects in parallel.
source share