gpt4 book ai didi

amazon-s3 - 异常 "The Content-MD5 you specified did not match what we received"

转载 作者:行者123 更新时间:2023-12-02 19:34:34 24 4
gpt4 key购买 nike

在测试将文件从 ec2 上传到 s3 的应用程序时,我遇到了一个异常(exception),这是我以前从未遇到过的。内容为:

Exception in thread "Thread-1" com.amazonaws.services.s3.model.AmazonS3Exception: The Content-MD5 you specified did not match what we received. (Service: Amazon S3; Status Code: 400; Error Code: BadDigest; Request ID: 972CB8E04388AB20), S3 Extended Request ID: T7bmFnQ2RlGWlJD+aGYfTy97XZw88pbQrwNB8YCezSjyq6O2joxHRP/6ko+Q2zZeGewkw4x/90k=
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1383)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:902)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)
at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3676)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1439)
at com.amazonaws.services.s3.transfer.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:131)
at com.amazonaws.services.s3.transfer.internal.UploadCallable.call(UploadCallable.java:123)
at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:139)
at com.amazonaws.services.s3.transfer.internal.UploadMonitor.call(UploadMonitor.java:47)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我可以做什么来修复这个错误?我在应用程序中使用了与之前相同的代码。

最佳答案

我想我已经解决了我的问题。我终于发现我的一些文件在上传过程中实际上发生了变化。由于文件是由另一个线程生成的,因此上传和生成是同时完成的。文件不能立即生成,在生成文件的过程中,可能同时上传,文件在上传过程中实际上发生了变化。

文件的md5是在开始上传时由AmazonS3Client创建的,然后将整个文件上传到S3,此时文件与开始上传的文件不同,因此md5实际上发生了变化。我将程序修改为单线程程序,问题再也没有出现。

关于amazon-s3 - 异常 "The Content-MD5 you specified did not match what we received",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36179310/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com