file upload to aws works

This commit is contained in:
catarak 2016-07-15 20:01:21 -04:00
parent c677c37597
commit b3956fb91b
2 changed files with 6 additions and 4 deletions

View file

@ -9,7 +9,7 @@ export function dropzoneAcceptCallback(file, done) {
name: file.name,
type: file.type,
size: file.size,
_csrf: document.findElementById('__createPostToken').value
// _csrf: document.getElementById('__createPostToken').value
},
{
withCredentials: true
@ -47,5 +47,6 @@ export function dropzoneCompleteCallback(file) {
};
console.log(json, JSON.stringify(json), JSON.stringify(json).replace('"', '\\"'));
inputHidden += `${window.btoa(JSON.stringify(json))}" />`;
document.findElementById('createPost').appendChild(inputHidden);
// document.getElementById('uploader').appendChild(inputHidden);
document.getElementById('uploader').innerHTML += inputHidden;
}

View file

@ -7,7 +7,8 @@ import { dropzoneAcceptCallback,
class FileUploader extends React.Component {
componentDidMount() {
Dropzone.options.uploader = {
Dropzone.autoDiscover = false;
this.uploader = new Dropzone('div#uploader', {
url: s3Bucket,
method: 'post',
autoProcessQueue: true,
@ -22,7 +23,7 @@ class FileUploader extends React.Component {
accept: dropzoneAcceptCallback,
sending: dropzoneSendingCallback,
complete: dropzoneCompleteCallback
};
});
}
render() {