簡體   English   中英

區域之間的 S3 CopyObjectRequest

[英]S3 CopyObjectRequest between regions

我正在嘗試在不同區域的 2 個 S3 存儲桶之間復制一些對象。

我有這個:

      static void PutToDestination(string filename)
      {
        var credentials = new Amazon.Runtime.BasicAWSCredentials(awsAccessKeyId, awsSecretKey);
        var client = new Amazon.S3.AmazonS3Client(credentials, Amazon.RegionEndpoint.GetBySystemName(awsS3RegionNameSource));

        CopyObjectRequest request = new CopyObjectRequest();
        request.SourceKey = filename;
        request.DestinationKey = filename;
        request.SourceBucket = awsS3BucketNameSource;
        request.DestinationBucket = awsS3BucketNameDest;

        try
        { 
        CopyObjectResponse response = client.CopyObject(request);
        }
        catch (AmazonS3Exception x)
        {
            Console.WriteLine(x);
        }
      }

我收到“您嘗試訪問的存儲桶必須使用指定端點尋址。請將所有未來請求發送到此端點。”

似乎沒有辦法為源和目標設置單獨的端點。

我應該看看其他方法嗎?

謝謝

我認為,如果您未明確指定區域,則跨區域復制應該可以工作。

請參閱文檔。

但是,加速將不起作用,並且將復制

COPY = GET + PUT

這是說明文件的摘錄,內容如下:

重要

Amazon S3 Transfer Acceleration不支持跨區域副本。

在您的代碼中,您要指定如下所示的區域。

AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                .withCredentials(new ProfileCredentialsProvider())
                .withRegion(clientRegion)
                .build();

而是初始化沒有區域的S3client,如下所示。

AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                .withCredentials(new ProfileCredentialsProvider()).build();

你試過這個嗎? https://github.com/aws/aws-sdk-java-v2/issues/2212 (構建 S3:Client 時提供目標區域)。 為我工作:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM