Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 带有UseSignatureVersion4选项的AWS GetBucketLocationRequest_.net_Amazon Web Services_Amazon S3 - Fatal编程技术网

.net 带有UseSignatureVersion4选项的AWS GetBucketLocationRequest

.net 带有UseSignatureVersion4选项的AWS GetBucketLocationRequest,.net,amazon-web-services,amazon-s3,.net,Amazon Web Services,Amazon S3,如何使用UseSignatureVersion4全局选项请求存储桶位置?事实上,我需要创建一个具有指定区域端点的AmazonS3Client实例。但是,例如,如果我有一个位于“us-west-2”区域的bucket,并使用“us-east-1”区域选项创建默认客户端AmazonS3Client,我会得到“授权标头格式错误;区域“us-east-1”错误;预期为“us-west-2”。错误”。但我事先不知道bucket的位置 AWSConfigs.S3Config.UseSignatureVers

如何使用UseSignatureVersion4全局选项请求存储桶位置?事实上,我需要创建一个具有指定区域端点的AmazonS3Client实例。但是,例如,如果我有一个位于“us-west-2”区域的bucket,并使用“us-east-1”区域选项创建默认客户端AmazonS3Client,我会得到“授权标头格式错误;区域“us-east-1”错误;预期为“us-west-2”。错误”。但我事先不知道bucket的位置

AWSConfigs.S3Config.UseSignatureVersion4 = true;
string location;

using (var tmpS3Client = new AmazonS3Client(accessInfo.AccessKey, accessInfo.SecretKey, RegionEndpoint.USEast1))
{
  var bucketLocationRequest = new GetBucketLocationRequest
  {
    BucketName = config.BucketName
  };
  GetBucketLocationResponse bucketLocationResponse = tmpS3Client.GetBucketLocation(bucketLocationRequest);
  location = bucketLocationResponse.Location.Value;
}