【发布时间】:2018-07-11 03:14:22
【问题描述】:
我在不同地区有两个存储桶,B1 在 APSoutheast2(悉尼),另一个 (B2) 在 USWest1(美国西部(加利福尼亚北部))。 我正在尝试使用 AWS S3 SDK (.NET) 将一些文件从 B1 移动到 B2,但我似乎没有看到一种简单的方法。
这是我的示例代码:
var sydneyClient = new AmazonS3Client("accessKeyID", "secretKey",
RegionEndpoint.APSoutheast2)
var fileInfo = new S3FileInfo(sydneyClient, "b1", "filePath");
if (!fi.Exists)
{
return;
}
fileInfo.MoveTo("b2", "filePath");
这给了我以下错误:
Amazon.S3.AmazonS3Exception: 'Error making request with Error Code
MovedPermanently and Http Status Code MovedPermanently. No further error
information was returned by the service.'
我认为这是因为 b2 与我执行此操作时位于不同的区域:
var listAllRequest = new ListObjectsRequest();
listAllRequest.BucketName = "b2";
var listAllResponse = sydneyClient.ListObjects(listAllRequest);
我知道了:
The bucket you are attempting to access must be addressed using the specified
endpoint. Please send all future requests to this endpoint
我知道我的“sydneyClient”无法访问在美国创建的另一个存储桶是有道理的,因为我在创建它时将区域指定为“RegionEndpoint.APSoutheast2”,并且根据 AWS 文档,每个区域都是独立的。
如果我尝试将文件从 b1 移动到 APSoutheast2 中的另一个存储桶,则可以正常工作。
我知道我可以将文件从 b1 下载到本地存储,为 b2 创建另一个 AmazonS3Client,然后进行上传。 但是在这种情况下,有没有一种简单的方法可以将文件从 b1 移动到另一个区域的存储桶中?
谢谢
【问题讨论】:
标签: c# amazon-web-services amazon-s3