I'm just a new with boto3 and i can not understand how i can get URL link for file that i have just uploaded to s3 amazon.
Please clarify.
Thank you
import boto3
s3 = boto3.resource('s3')
data = open ('file.xlsx', 'rb')
s3.Bucket ('dimxxx1').put_object (Key='file.xlsx', Body=data)
You can get the resource URL either by calling getResourceUrl or getUrl . AmazonS3Client s3Client = (AmazonS3Client)AmazonS3ClientBuilder. defaultClient(); s3Client. putObject(new PutObjectRequest("your-bucket", "some-path/some-key.
Get an S3 Object's URL #Navigate to the AWS S3 console and click on your bucket's name. Use the search input to find the object if necessary. Click on the checkbox next to the object's name. Click on the Copy URL button.
A presigned URL gives you access to the object identified in the URL, provided that the creator of the presigned URL has permissions to access that object.
First, the better way to upload would be:
import boto3
s3 = boto3.resource('s3')
s3.Bucket('dimxxx1').upload_file('/tmp/file.xlsx', 'file.xlsx')
To obtain the URL, you can construct it from the basic elements:
http://s3-REGION-.amazonaws.com/BUCKET-NAME/KEY
For example:
http://s3-ap-southeast-2.amazonaws.com/dimxxx1/file.xlsx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With