我只是 boto3 的新手,我不明白如何获取刚刚上传到 s3 amazon 的文件的 URL 链接。
请澄清。
谢谢
import boto3
s3 = boto3.resource('s3')
data = open ('file.xlsx', 'rb')
s3.Bucket ('dimxxx1').put_object (Key='file.xlsx', Body=data)
请您参考如下方法:
首先,更好的上传方式是:
import boto3
s3 = boto3.resource('s3')
s3.Bucket('dimxxx1').upload_file('/tmp/file.xlsx', 'file.xlsx')
要获取 URL,您可以从基本元素构造它:
http://s3-REGION-.amazonaws.com/BUCKET-NAME/KEY
例如:
http://s3-ap-southeast-2.amazonaws.com/dimxxx1/file.xlsx
