【问题标题】:AWS- S3 Multi-Region Access point use in C#AWS- S3 多区域访问点在 C# 中的使用
【发布时间】:2023-01-20 21:19:52
【问题描述】:

实际上,我需要在我的 c# 应用程序中使用 s3 多区域功能。

我已经在我的项目中安装了 AWSSDK dll。

我创建了 3 个不同区域的存储桶,例如 us-west-2、us-east-1 和 us-east2。 并在创建多区域接入点时添加了这 3 个存储桶。

创建此接入点后,我只是从 s3 多区域板复制了 ARN 名称并将其用于我的 c# 代码中, 我只是在我的代码中用多区域访问点替换存储桶名称,如下所示:

var config=new AmazonS3Config();
config.UseArnRegion=false;
config.RegionEndPoint=RegionEndPoint.USWest2;

var s3Client=new AmazonS3Client(config);

before using multi region the code was like this and its working:
S3FileInfo info=new S3FileInfo(s3Client, "s3bucketname","Dummy.txt");

and after adding the multi region the code look like this and getting below error:
S3FileInfo info=new S3FileInfo(s3Client, "arn:aws:s3::\<account_number\>/---.mrap","Dummy.txt");

i have tried this below 2 options also but its not working getting error "The specified bucket is does not exist.."
S3FileInfo info=new S3FileInfo(s3Client, "---.mrap","Dummy.txt");
S3FileInfo info=new S3FileInfo(s3Client, "---.mrap.accesspoint.s3-global.amazonaws.com","Dummy.txt");

bool fileExist=info.Exists;

MessageBox.Show(fileExist.ToString());

我收到如下错误: Amazon.Runtime.AWSCommonRuntimeException:尝试发出需要实施 AWS Signature V4a 的请求。将对 AWSSDK.Extensions.CrtIntegration NuGet 包的引用添加到您的项目以包含 AWS Signature V4a 签名者。

请让我知道我哪里错了。请帮我解决这个问题。

【问题讨论】:

    标签: c# amazon-s3


    【解决方案1】:

    这是适合您的解决方案。

    var mrapArn = "arn:aws:s3::{your-account-id-here}:accesspoint/{mrap-alias-here}";
    string objKey = "folderA/folderB/abc.jpeg";
    
    AWSConfigsS3.UseSignatureVersion4 = true;
    var client = new AmazonS3Client(new AmazonS3Config { UseArnRegion = true });
    
    var file = await client.GetObjectAsync(new GetObjectRequest { BucketName = mrapArn, Key = objKey });
    
    Console.WriteLine(file.VersionId);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-21
      • 1970-01-01
      • 2019-01-07
      • 2017-03-14
      • 1970-01-01
      • 2017-11-19
      相关资源
      最近更新 更多