Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon s3 .NET SDK , the bucket you are trying to access must be addressed using specfied endpoint

I am using amazon .NET SDK in widows phone 8 app for uploading images, the code was working fine.Now I get an exception

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

I have updated to latest version of SDK 2.0.2.2, Has anything changed with the update?

My code

string awsID = "myid";
    string secretKey = "mysecretkey";
    try{
   AmazonS3Client s3Client = new AmazonS3Client(awsID, secretKey,RegionEndpoint.USWest1);
     string s="";
     if (IsolatedStorageSettings.ApplicationSettings.Contains("selectedphoto1"))
     {

       s = IsolatedStorageSettings.ApplicationSettings["selectedphoto1"] as string;
 }
     var InputStream = App.GetResourceStream(new Uri("appname;component/Assets  /call.png", UriKind.Relative));
        var request = new PutObjectRequest()
        {
            BucketName = "mybucketname",

            ContentType="image/png",
           Key=s+".jpg",
           InputStream = myFileStream,
        };

        await s3Client.PutObjectAsync(request);
 }
    catch (Exception ex)
    {
        Console.Write(ex.InnerException);
    }
like image 228
Prasanna Aarthi Avatar asked Nov 22 '13 05:11

Prasanna Aarthi


1 Answers

This is happening because bucket region is incorrect. Check your region on Amazon console at S3 bucket and configure the same in config file and code.

For example:

AmazonS3Client s3Client = new AmazonS3Client(awsID, secretKey, RegionEndpoint.APNortheast1);

<add key="AWSRegion" value="eu-west-1" />
like image 138
Ajay Nikam Avatar answered Sep 22 '22 21:09

Ajay Nikam