[英]AWS- S3 Multi-Region Access point use in C#
Actually, I need to use the s3 multi-region feature in my c# application.实际上,我需要在我的 c# 应用程序中使用 s3 多区域功能。
I have installed the AWSSDK dll in my project.我在我的项目中安装了 AWSSDK dll。
I have created 3 buckets with different regions like us-west-2,us-east-1, and us-east2.我创建了 3 个不同区域的存储桶,例如 us-west-2、us-east-1 和 us-east2。 and added these 3 buckets while creating the Multi-Region Access point.并在创建多区域接入点时添加了这 3 个存储桶。
After creating this Access Point, I just copied the ARN Name from the s3 multi-region board and used it in my c# code, I just replace the bucket name with Multi-Region Access Point in My code looks like below:创建此接入点后,我只是从 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());
I am getting errors as below: Amazon.Runtime.AWSCommonRuntimeException: Attempting to make a request that requires an implementation of AWS Signature V4a.我收到如下错误:Amazon.Runtime.AWSCommonRuntimeException:尝试发出需要实施 AWS Signature V4a 的请求。 Add a reference to the AWSSDK.Extensions.CrtIntegration NuGet package to your project to include the AWS Signature V4a signer.将对 AWSSDK.Extensions.CrtIntegration NuGet package 的引用添加到您的项目以包含 AWS Signature V4a 签名者。
Please let me know where I am wrong.请让我知道我哪里错了。 Please help me to resolve this issue.请帮我解决这个问题。
Here's a solution for you.这是适合您的解决方案。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.