Upload images on Amazon S3. source code

可紊 提交于 2019-12-13 07:21:52

问题


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.

  • 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();
    

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


回答1:


Finally i find the solution by myself.

AmazonS3Config asConfig = new AmazonS3Config()
{
    ServiceURL = "http://irisdb.s3-ap-southeast2.amazonaws.com/",
    RegionEndpoint = Amazon.RegionEndpoint.APSoutheast2
};

Making RegionalEndPoints correct. my application run like a charm. Thanks for everyone.



来源:https://stackoverflow.com/questions/38005716/upload-images-on-amazon-s3-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!