p5.js-web-editor/client/modules/IDE/components/FileUploader.jsx
Cassie Tarakajian e87390adb9 update eslint to latest version, fix lots of linting errors (#308)
* update eslint and dependencies, fix linting errors that can be fixed with --fix

* fix lots of linting errors

* update eslintrc, fix some linting errors

* fix all server side linting errors, untested

* fix errors that fixing linting errors had caused

* fix client side eslint errors

* fix client side linting errors

* fix refs lint errors

* fix more linting errors

* update eslint and dependencies, fix linting errors that can be fixed with --fix

* fix lots of linting errors

* update eslintrc, fix some linting errors

* fix all server side linting errors, untested

* fix errors that fixing linting errors had caused

* fix client side eslint errors

* fix client side linting errors

* fix refs lint errors

* fix more linting errors

* fix some accessibility linting errors

* fix a lot of linting errors

* fix a billion more linting errors

* hopefully fix all linting errors, still need to test

* fix bugs that fixing linting had caused
2017-02-22 14:29:35 -05:00

67 lines
2 KiB
JavaScript

import React, { PropTypes } from 'react';
import Dropzone from 'dropzone';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as UploaderActions from '../actions/uploader';
const s3Bucket = `https://s3-us-west-2.amazonaws.com/${process.env.S3_BUCKET}/`;
class FileUploader extends React.Component {
componentDidMount() {
this.createDropzone();
Dropzone.autoDiscover = false;
}
createDropzone() {
this.uploader = new Dropzone('div#uploader', {
url: s3Bucket,
method: 'post',
autoProcessQueue: true,
clickable: true,
maxFiles: 6,
parallelUploads: 2,
maxFilesize: 5, // in mb
maxThumbnailFilesize: 8, // 8 mb
thumbnailWidth: 200,
thumbnailHeight: 200,
// TODO what is a good list of MIME types????
acceptedFiles: `image/*,audio/*,text/javascript,text/html,text/css,
application/json,application/x-font-ttf,application/x-font-truetype,
text/plain,text/csv,.obj,video/webm,video/ogg,video/quicktime,video/mp4,
.otf,.ttf`,
dictDefaultMessage: 'Drop files here to upload or click to use the file browser',
accept: this.props.dropzoneAcceptCallback,
sending: this.props.dropzoneSendingCallback,
complete: this.props.dropzoneCompleteCallback,
// error: (file, errorMessage) => {
// console.log(file);
// console.log(errorMessage);
// }
});
}
render() {
return (
<div id="uploader" className="uploader dropzone"></div>
);
}
}
FileUploader.propTypes = {
dropzoneAcceptCallback: PropTypes.func.isRequired,
dropzoneSendingCallback: PropTypes.func.isRequired,
dropzoneCompleteCallback: PropTypes.func.isRequired
};
function mapStateToProps(state) {
return {
files: state.files,
project: state.project
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(UploaderActions, dispatch);
}
export default connect(mapStateToProps, mapDispatchToProps)(FileUploader);