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

前端 未结 2 720
感情败类
感情败类 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:05

    There is few ways to check. First, you should always make sha256 hash for your file. When you upload, remember to put this info inside the Meta part of the object upload script.

    • read the whole file, retrieve the sha256 has from the header meta, and recalculate the has to check it is tally.
    • Add an events for the bucket on PUT. When file successfully uploaded, send the events to a queue which you can inspect. So in success upload but your program crash afterwards, you still have a fall back than reupload the file again.

提交回复
热议问题