Boto3: Verify if the file has been uploaded using upload_file()

前端 未结 2 700
感情败类
感情败类 2021-01-03 04:16

I\'m making a backup script using boto3 using this line to upload the item:

bucket.upload_file(backup_file_name,bucket_path+backup_file_name)
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 05:01

    It will raise boto3.exceptions.S3UploadFailedError. You can also do a head_object request to verify that the object looks like it should. This will raise a botocore.ClientError with the code 404 if the object does not exist.

提交回复
热议问题