gpt4 book ai didi

.net - 未配置 RegionEndpoint 或 ServiceURL

转载 作者:行者123 更新时间:2023-12-02 21:59:26 27 4
gpt4 key购买 nike

我正在编写代码将文件上传到 AWS S3 并收到此异常:

AmazonClientException: No RegionEndpoint or ServiceURL configured

我的代码:

Console.WriteLine("ready to upload");
AWSCredentials credentials;
credentials = new BasicAWSCredentials(accessKeyID.Trim(), secretKey.Trim());
AmazonS3Client s3Client = new AmazonS3Client(accessKeyID.Trim(), secretKey.Trim(), Amazon.RegionEndpoint.USEast1);
Console.WriteLine("Successful verification");
Console.WriteLine("Check if the bucket exists");
if (!CheckBucketExists(s3Client, bucketName))
{
s3Client.PutBucket(bucketName);
Console.WriteLine("create bucket");
}
TransferUtility utility = new TransferUtility();
Console.WriteLine("Upload Directory......");
//exception here
utility.UploadDirectory(@"E:\telerikFile\13ginabdfglil.com", bucketName);

异常(exception):

Amazon.Runtime.AmazonClientException: No RegionEndpoint or ServiceURL configured
Amazon.Runtime.ClientConfig.Validate()
Amazon.S3.AmazonS3Config.Validate()
Amazon.Runtime.AmazonServiceClient..ctor(AWSCredentials credentials, ClientConfig config)
Amazon.S3.AmazonS3Client..ctor()
Amazon.S3.Transfer.TransferUtility..ctor()
Telerik2Amazon.Program.UploadFile()

我应该做什么?

最佳答案

错误的简短回答...

Amazon.Runtime.AmazonClientException: No RegionEndpoint or ServiceURL configured

...在我的例子中,是在构建客户端对象时指定一个区域(对我来说是 AmazonSimpleEmailServiceClient)。

假设您使用的是BasicAWSCredentials,那么请尝试以下操作:

var credentials = new BasicAWSCredentials(accessKeyID, secretKey);

new AmazonS3Client(credentials, RegionEndpoint.USEast1);

// ^^^^^^^^^^^^^^^^^^^^^^ add this

关于.net - 未配置 RegionEndpoint 或 ServiceURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45055665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com