在Amazon S3上上传图像。源代码 [英] Upload images on Amazon S3. source code
问题描述
我正在尝试在Amazon s3上上传图像。我尝试了不同的源代码,但没有成功。我坚持要区分黑白IAmazonClient,Amazons3对象等。
谁能给我例子并指导我如何在s3上上传图像。我正在开发REST服务,可以捕获图像并上传到Amazon s3。
I am trying to upload images on Amazon s3. I have tried different source codes but no vain.I am stuck to differentiate b/w IAmazonClient, Amazons3 objects etc. can anyone give me example and direct me how can i upload images on s3.I am developing REST service that can capture images and upload on amazon s3.
- 我的存储桶在澳大利亚悉尼。
- < a href = http://irisdb.s3apsoutheast2 rel = nofollow> http://irisdb.s3apsoutheast2 。
amazonaws.com / - accesskey = xxxxxxxx
- secretKey = cxxxxxxxxx
-
端点:irisdb.s3websiteapsoutheast2。
amazonaws.com
- My bucket is in Sydney Australia.
- http://irisdb.s3apsoutheast2. amazonaws.com/
- accesskey = "xxxxxxxx"
- secretKey = "cxxxxxxxxx"
Endpoint: irisdb.s3websiteapsoutheast2. amazonaws.com
string accessKey = "xxxx";
string secretKey = "mxxxxx";
string bucketName = "irisdb"; // Set to a bucket you create
// Create S3 service client.
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3Config asConfig = new AmazonS3Config()
{
ServiceURL = "http://irisdb.s3-ap-southeast2.amazonaws.com/",
ServiceEndPoint = "irisdb.s3-website-ap-southeast2.amazonaws.com" //error here (cannot convert string to endpoints)
};
AmazonS3Client client2 = new AmazonS3Client(awsCredentials, asConfig);
ListBucketsResponse response = client2.ListBuckets();
我知道我需要提供亚马逊服务。 .ap-southeast-2在serviceEndPoint中,但Amazon.EndPoint
请帮助
I know i need to provide Amazon.Endpoints.ap-southeast-2 in serviceEndPoint but "ap-southeast-2" not exist in the definition of Amazon.EndPoint Please help
推荐答案
最后我自己找到解决方案。
Finally i find the solution by myself.
AmazonS3Config asConfig = new AmazonS3Config()
{
ServiceURL = "http://irisdb.s3-ap-southeast2.amazonaws.com/",
RegionEndpoint = Amazon.RegionEndpoint.APSoutheast2
};
使RegionalEndPoints正确无误。我的应用程序像一个魅力一样运行。谢谢大家。
Making RegionalEndPoints correct. my application run like a charm. Thanks for everyone.
这篇关于在Amazon S3上上传图像。源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!