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);
}
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With