'What is variable.on meaning with meteor, mongodb and reactjs?
I’m trying to understand what this function is doing and I have a question regarding the below code.
const saveFile = (event, files) => {
const file = new FS.File(f);
file.profileId = card.profileId;
file.cardId = card.cardId;
const upload = UserFiles.insert(
{
file: f,
streams: 'dynamic',
chunkSize: 'dynamic',
meta: {
profileId: card.profileId,
cardId: card._id,
},
},
false,
);
upload.on('end', function (error, fileObj) { // here is my question
if (error) {
alert(`${error}`);
} else {
console.log(fileObj);
}
});
upload.start();
};
Also, I’m using the package called Meteor-CollectionFS and GridFS.
My question is what
upload.on('end', function (error, fileObj) {......
means?
What is this part of the code doing?
Also
const upload = UserFiles.insert(
{
file: f,
streams: 'dynamic', .....
is a little strange to me.
I understood they were trying to insert values to UserFiles collection , but why are they const upload for this inserting?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
