【发布时间】:2014-02-23 12:04:37
【问题描述】:
我正在使用 AWS S3 访问我的 HTML5 应用程序中的文件。以下代码在我的笔记本电脑上运行良好,但在移动设备(iphone)上失败。非常感谢任何帮助。
AWS.config.region = 'us-west-2';
var bucket = new AWS.S3({params: {Bucket: 'mybucket'}});
bucket.getObject({Key: myfile}, function (error, data) {
if (error != null) {
alert("Failed to retrieve " + myfile + " :" + error);
} else {
//alert("Loaded " + data.ContentLength + " bytes");
localStorage[myfile] = data.Body.toString();
// do something with data.body
}});
我得到的错误是: "http //本地主机 获取 foo.json 失败:NetworkingError: Network Failure"
我对此存储桶有以下 CORS 配置
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
</CORSRule>
【问题讨论】:
标签: javascript amazon-s3