I need a way to let my user drag and drop a file (text) which then will be parsed by the application. I have tested the package chfritz:filedrop but I cant understand how to open / read / grab the file. The drop seems to work but no handle to the file.
Have anyone used the package or any other suggestions would be great?
Thanks for any help
If you want to process the file using filedrop (ie on the browser side), code snippet below could help you get started. Otherwise you could checkout what @shock mentioned meteor-uploads
Template.myFileDrop.helpers({
dropHandlers: function(){
var self = this;
return {
onEnter: function(event) {
console.log("enter", event);
},
onDrop: function(files) {
console.log("dropped", files);
var reader = new FileReader();
var name = files[0].name;
reader.onload = function(e) {
var data = e.target.result;
};
reader.readAsBinaryString(files[0]);
}
};
},
});
Thanks, its working. I don’t know what misstake I did, I could not see the file when I debug (in webstorm) but it seems to be there and working. Thanks a lot.
Thanks for the suggestion. I don’t need to upload anything, just parse but I will check it out. Thanks.
here’s the error when adding the filedrop.
$ meteor add filedrop
=> Errors while parsing arguments:
While adding package filedrop:
error: no such package
Any idea why?
It’s because the GitHub README has got it wrong. If you look in atmosphere you’ll see it’s meteor add chfritz:filedrop
.