I am trying to write a Ruby script that uploads a file to AWS and makes the file public. I have done the following:
s3 = Aws::S3::Resource.new(
credentials: Aws::Credentials.new(KEY, SECRET),
region:'us-west-2'
)
obj = s3.bucket('stg-db').object('key')
obj.upload_file(filename)
This seems to work fine except that the file is not accessible and I cannot get a public URL for it. But when I enter S3, I see that my file is just fine.
To make it public, I changed the last line to
obj.upload_file(filename, acl: 'public-read')
But I get an access denied error when I do this. Is there some kind of permission setting that I skip in my S3 bucket that causes problems, or am I calling it that wrong?
source
share