I have the following code that is used to upload a local file to Amazon S3 Bucket:
require 'aws/s3'
module AmazonS3
def self.upload_file(local_file)
bucket_name = "bucketfortest"
s3 = AWS::S3.new(
:access_key_id => ENV["AMAZON_ACCESS_KEY"],
:secret_access_key => ENV["AMAZON_SECRET_KEY"]
)
key = File.basename(local_file)
amazon_object = s3.buckets[bucket_name].objects[key].write(:file => local_file)
return amazon_object #How can I get the URL of the object here?
end
end
I based this code on: Upoad file S3
I am trying to find out a way to get the URL of the object that was just uploaded, but I fail to find what is it. I tried .url
, but that gives me an Undefined Method. I fail to see anything in the docs either.