简体   繁体   English

AWS- S3 多区域访问点在 C# 中的使用

[英]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.

相关问题 为多区域保持 AWS API Gateway-Rest APIs 同步 - Keeping AWS API Gateway-Rest APIs on Sync for multi-region 如何构建多区域 firebase 应用程序? - How to structure a multi-region firebase app? Postgres 数据库的多区域可用性能够为我们的客户提供 4+9 的可用性? - Multi-Region Availability for Postgres Database to be able to offer our clients 4+ 9's of availability? 多区域 Aurora 上的多主机 - 可能吗? - multi-master over multi-region Aurora - possible? 限制 AWS EC2 实例仅访问同一区域中的 S3 存储桶 - Limit AWS EC2 Instances to Access S3 Buckets in the Same Region ONLY 如何在 Flink 中使用 sinkTo 在 AWS S3 中写入多文件 - How to use sinkTo in Flink to write multi file in AWS S3 从 Spring 引导应用程序写入转发的多区域 Aurora - Multi-Region Aurora with write forwarding from Spring Boot Application 如何在 Cosmos DB 中测试多区域写入 - How to test multi-region write in Cosmos DB AWS S3 跨区域复制是否对多个区域使用相同的 URL? - Does AWS S3 cross-region replication use same URL for multiple regions? 如何在 C# SDK 中获取 AWS S3 DeleteMarkers? - How to fetch AWS S3 DeleteMarkers in C# SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM