Hap*_*ung 2 c# aws-sdk aws-sdk-net
有谁知道如何使用 s3 net API 添加自定义端点?
\n详细信息\xef\xbc\x9ahttps://github.com/aws/aws-sdk-net/issues/1283\n代码语言:C#
sServiceUrl 值 =“192.168.199.216:7480”
\n当我调用DoesS3BucketExist函数时,我取消了Exception\xef\xbc\x88System.UriFormatException\xef\xbc\x89
\n这是我的代码
\npublic IAmazonS3 CreateClient(string sAccessKeyId, string sAccessKeySecret, string sServiceUrl)\n{\n AmazonS3Client s3Client = null;\n try\n {\n AmazonS3Config config = new AmazonS3Config();\n config.ServiceURL = sServiceUrl;\n config.UseHttp = false;\n config.SignatureVersion = "v4";\n AWSConfigsS3.UseSignatureVersion4 = true;\n\n s3Client = new AmazonS3Client(\n sAccessKeyId,\n sAccessKeySecret,\n config\n );\n }\n catch (Exception ex)\n {\n LogHelper.WriteLog("AWS\xe9\x85\x8d\xe7\xbd\xae", ex, "\xe5\x88\x9b\xe5\xbb\xbaAmazonS3Client\xe5\xa4\xb1\xe8\xb4\xa5\xef\xbc\x81");\n }\n return s3Client;\n}\n\npublic bool DoesBucketExist(string bucketName)\n{\n bool bIsExist;\n if (this.Client != null)\n {\n bIsExist = this.Client.DoesS3BucketExist(bucketName);\n }\n else\n {\n bIsExist = false;\n }\n return bIsExist;\n}\nRun Code Online (Sandbox Code Playgroud)\n我想设置此属性AWSConfigs.EndpointDefinition = @"c:pathtoendpoints.xml";,但我不知道如何自定义 endpoints.json 文件。
这对我来说太难了,也许我需要上帝帮助我!任何帮助将不胜感激\xef\xbc\x81
\nstatic void Main(string[] args)
{
string accessKey = "";
string secretKey = "";
AmazonS3Config config = new AmazonS3Config()
{
ServiceURL = string.Format("http://{0}", "192.168.199.216:7480"),
UseHttp = true,
ForcePathStyle = true,
ProxyHost = "192.168.199.216",
ProxyPort = 7480
};
AWSCredentials creds = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3Client s3Client = new AmazonS3Client(creds, config);
ListBucketsResponse response = s3Client.ListBuckets();
foreach (S3Bucket b in response.Buckets)
{
Console.WriteLine("{0}\t{1}", b.BucketName, b.CreationDate);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5254 次 |
| 最近记录: |