gpt4 book ai didi

java - S3Client跨区域copyObject

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

我正在尝试在不同区域的 2 个 S3 存储桶之间复制文件:

US_EAST_1 ---> EU_CENTRAL_1

使用以下命令:

s3client.copyObject(sourceBucket, sourceFile, DestBucket, DestFile);

我启动 s3client 时未提供区域以允许其在这两个区域中工作,但出现以下错误:

Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. (Service: Amazon S3; Status Code: 301; Error Code: PermanentRedirect; Request ID: C2E6D084FF257437), S3 Extended Request ID: rXDTuqPSCCKWoF8luScpL+/po93oEQC2VSNUBQtSLBh5q8yEAO0WwK8FnBMPGEZQjS+zwkkHWBg= at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1305) at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:852) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:630) at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:405) at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:367) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:318) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3787) at com.amazonaws.services.s3.AmazonS3Client.copyObject(AmazonS3Client.java:1530) at com.amazonaws.services.s3.AmazonS3Client.copyObject(AmazonS3Client.java:1487)

我正在使用“aws-java-sdk”版本:“1.11.7”

如何克服这个错误?

最佳答案

客户端无法配置为“在两个区域都工作”。它必须配置一个区域,以便它在单个区域中工作。

在存储桶之间(区域之间)复制对象时,将客户端设置为目标区域。然后,指定源存储桶和目标存储桶。

关于java - S3Client跨区域copyObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37816755/

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