Created
March 18, 2016 15:52
-
-
Save mmintel/070976906e708048e174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Gallery = React.createClass({ | |
| _handleUpload(files) { //this function is called whenever a file was dropped in your dropzone | |
| _.each(files, function(file) { | |
| file.owner = Meteor.userId(); //before upload also save the owner of that file | |
| Images.insert(file, function(err, fileObj) { | |
| if (err) { | |
| console.log(err); //in case there is an error, log it to the console | |
| } else { | |
| //the image upload is done successfully. | |
| //you can use this callback to add the id of your file into another collection | |
| //for this you can use fileObj._id to get the id of the file | |
| } | |
| }); | |
| }); | |
| }, | |
| render() { | |
| return( | |
| <div> | |
| <Dropzone onDrop={this._handleUpload}> | |
| <div>Try dropping some files here, or click to select files to upload.</div> | |
| </Dropzone> | |
| </div> | |
| ) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment