I am using Ember-uploader to upload files directly from browser to s3. The cors policy that i have set is as follows
<?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>
Api response from nodejs server is as follows
{
"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"
}
The issue is the upload fails because of
Failed to load http://georoot.s3.amazonaws.com/: Response for preflight is invalid (redirect)
On inspecting the network logs it shows me a 307
redirect and the upload fails. The configuration i have for the uploader plugin is as follows
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], { });
}
}
});
Can someone explain where i am going wrong ?
Aucun commentaire:
Enregistrer un commentaire