【发布时间】:2019-06-06 04:08:39
【问题描述】:
我知道如何使用 boto3 将文件上传到 s3 存储桶中。但是我已经使用了我的功能,我想检查图像是否成功上传到 s3 存储桶上,如果上传了,那么我想执行一个操作。
所以这里是这样的例子,
import boto3
def upload_image_get_url(file_name, bucket, key_name):
s3 = boto3.client("s3")
result = s3.upload_file(file_name, bucket, key_name) # Here I got none so How I will check like file is upoaded or not?
if result == 'success' or result == True:
response = "https://{0}.s3.us-east-2.amCCazonaws.com/{1}".format(bucket, key_name)
else:
response = False
return response
所以我的要求是直截了当的,如果我在文件上传中获得成功,那么我将返回 s3 url 作为响应。所以请帮助我,我们将不胜感激。
【问题讨论】:
标签: python amazon-web-services amazon-s3 boto3