I know how to upload the file on the s3 bucket using boto3. But I have used it my function where I want to check like an image is successfully uploaded on the s3 bucket or not and if it is uploaded then I want to perform an action.
So here is the example like,
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
So my requirement is straight forward like if I got success in file upload then I will return s3 url in response. So please help me and your help will be appreciated.