我在 Widows Phone 8 应用程序中使用 amazon .NET SDK 来上传图像,代码工作正常。现在出现异常
您尝试访问的存储桶必须使用
指定的端点。请将所有未来请求发送到此端点。
我已经更新到最新版本的 SDK 2.0.2.2,更新后有什么变化吗?
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);
}
发生这种情况是因为存储桶区域不正确。
在 Amazon 控制台的 S3 存储桶中检查您的区域,并在配置文件和代码中配置相同的区域。
例如:
AmazonS3Client s3Client = new AmazonS3Client(awsID, secretKey, RegionEndpoint.APNortheast1);
<add key="AWSRegion" value="eu-west-1" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)