I am trying to write a very simple script to download a file and upload it to an S3 bucket that I created, but I keep getting the "Access Denied" error, even though I am providing credentials that work elsewhere with my rails application. This script is not being run on the server itself -- just on the command line, if that makes a difference.
file = open('test.png', 'wb') do |file|
file << open('http://ift.tt/1PbAVdD').read
end
Aws.config.update({
region: 'us-east-1',
credentials: Aws::Credentials.new('my_access_key_id',
'my_secret_key_id')
})
s3 = Aws::S3::Client.new
bucket = Aws::S3::Bucket.new('my-bucket-name', client: s3)
obj = bucket.object('blahblah/test.png')
obj.upload_file(file.path, content_type: 'image/png')
Any ideas? Thanks.
Aucun commentaire:
Enregistrer un commentaire