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, name: file.name,
type: file.type, type: file.type,
size: file.size, size: file.size,
_csrf: document.findElementById('__createPostToken').value // _csrf: document.getElementById('__createPostToken').value
}, },
{ {
withCredentials: true withCredentials: true
@ -47,5 +47,6 @@ export function dropzoneCompleteCallback(file) {
}; };
console.log(json, JSON.stringify(json), JSON.stringify(json).replace('"', '\\"')); console.log(json, JSON.stringify(json), JSON.stringify(json).replace('"', '\\"'));
inputHidden += `${window.btoa(JSON.stringify(json))}" />`; 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 { class FileUploader extends React.Component {
componentDidMount() { componentDidMount() {
Dropzone.options.uploader = { Dropzone.autoDiscover = false;
this.uploader = new Dropzone('div#uploader', {
url: s3Bucket, url: s3Bucket,
method: 'post', method: 'post',
autoProcessQueue: true, autoProcessQueue: true,
@ -22,7 +23,7 @@ class FileUploader extends React.Component {
accept: dropzoneAcceptCallback, accept: dropzoneAcceptCallback,
sending: dropzoneSendingCallback, sending: dropzoneSendingCallback,
complete: dropzoneCompleteCallback complete: dropzoneCompleteCallback
}; });
} }
render() { render() {