I’m having an issue that when I upload a jpg image file, this keeps uploading same jpg image repeatedly.
I’m also using Meteor-CollectionFS and Meteor-Files package.
This happens only with jpg image and don’t know how to investigate.
What would you do to examine this bug?
Here is code.
const saveFile = (event, files) => {
if (files?.length) {
for (let i = 0, ln = files.length; i < ln; i++) {
const f = files[i].serverId.fileObj;
const file = new FS.File(f);
file.boardId = file.boardId;
file.aimId = file.aimId;
const upload = Collection1.insert(
{
file: f,
streams: 'dynamic',
chunkSize: 'dynamic',
meta: {
boardId: file.boardId,
fileId: file._id,
},
},
false,
);
console.log('f',f); // this output once
upload.on('end', function (error, fileObj) {
console.log(`fileObj:`, fileObj); // multiple outcome
console.log(`error:`, error); // multiple outcome
const newFileObj = {...fileObj, ...upload.file};
Collection2.findOne({_id: file._id}).addAttachment(
newFileObj,
file,
);
});
upload.start();
Meteor.myFunctions.track(TAPi18n.__('attachment'), {
category: 'Issues',
});
setDialogOpen(false);
}
} else {
setDialogOpen(false);
}
};
What I could tell is inside upload.on
, when I upload a jpg image, it seems like error
, fileObj
show multiple output on console
and insert multiple data into Collection.
Also, there is a error
message saying error: Uncaught TypeError: b.data.f.slice is not a function
What should I do to investigate this?
Additional information
I tried to upload .jpeg
image and I was able to update just one image.
So this seems like happening only .jpg
.