如何保证文件上传到存储?

How to ensure file upload to storage?

基本上我可以使用已签名的 url 将视频上传到 S3 存储桶,该存储桶目前运行良好,但我想知道是否有任何预防措施可以确保视频文件能够上传。

我想您想确保视频已完整上传。为了确保文件的完整性,您可以在调用 api 上传文件时提供对象的 base64 编码 MD5 哈希值。

If the checksum that Amazon S3 calculates during the upload doesn't match the value that you entered for --content-md5, S3 won't store the object. Instead, you receive an error message in response. For more information, see Does the AWS CLI validate checksums?

步骤总结:

  • 在本地计算对象的md5散列

  • 上传文件时,提供计算的哈希值作为参数。例如

     aws s3api put-object --bucket bucket --key file.txt --body ./path --content-md5 samplemd5value1267==
    

Checking the integrity of the object being uploaded to amazon s3