我正在使用Ember-uploader将文件直接从浏览器上传到s3。我设定的角色政策如下
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://localhost:4200</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
来自nodejs服务器的Api响应如下
{
"acl":"public-read",
"awsaccesskeyid":"AKIAJJC5RMTQE7RNOUAA",
"bucket":"georoot",
"Cache-Control":"max-age=630720000, public",
"Content-Type":"image/png",
"expires":"2018-06-06T13:00:19.000Z",
"key":"uploads/2018-05-30-212251_1366x768_scrot.png",
"policy":"eyJleHBpcmF0aW9uIjoiMjAxO9",
"signature":"li7WlpwEYqX+jWqkjw72QE2DWug=",
"success_action_status":"201"
}
问题是由于
导致上传失败无法加载http://georoot.s3.amazonaws.com/:预检的响应无效(重定向)
在检查网络日志时,它会向我显示307
重定向,并且上传失败。我对上传器插件的配置如下
import Component from '@ember/component';
import EmberUploader from 'ember-uploader';
import config from '../config/environment';
export default EmberUploader.FileField.extend({
filesDidChange(files) {
const uploader = EmberUploader.S3Uploader.create({
url: config.APP.UPLOAD_ENDPOINT
});
uploader.on('didUpload', response => {
let uploadedUrl = $(response).find('Location')[0].textContent;
uploadedUrl = decodeURIComponent(uploadedUrl);
});
if (!Ember.isEmpty(files)) {
uploader.upload(files[0], { });
}
}
});
有人可以解释我哪里出错吗?