Insert same files over and over with Meteor-CollectionFS and Meteor-Files | what should I do to investigate this code?

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.

Following because honestly dude I cant even get that library to take a file and had nothing but problems with it, created a issue on git and was met with total animosity. Looking forward to seeing how to make it work!

Hi @miki11,

I am curious what is your case. Do you need privacy/confidentiality for your files or can they be shared like in social media, where you can get a public URL?
What is your storage adapter?

Unfortunately I can’t because the files are way too big and really complicated.

If I understood the storage adapter correctly, I use the Studio 3T for storing collections and documents.

You might want to take a look at Filepond.

I use this to upload files and use Meteor-CollectionFS and Meteor-Files to insert documents into Collection!

Hi @miki11 what I meant is not whether you can share them here but if you need, in your project, for those files to be private/confidential.

There are different technologies to use if you don’t need a lot of privacy. I am afraid you cannot use Studio 3T to store collections or Documents.

1 Like

I would say they don’t need a lot of privacy.

Could you tell me which package/library you recommend for this case?
I would like to look into!

Hi @miki11,

as mentioned to you in private, you can call me at any time. Otherwise you can have a look at this: S3 file upload - is slingshot still usable ? alternatives? - #15 by ivo

The subject is vast but I thing the thread above has all the necessary details.

1 Like

My software is for sensitive data and used by government and military so it must be on-site on localhost machines and cannot use cloud at all.

I avoid all cloud anyways, the pricing is uncompetitive and means I make a small margin of profit if I do use them. I see using cloud as a self defeat - why would I study and become certified by the Linux foundation to not use my skillset and just take an off the shelf hosted solution that costa fortune when I have racks of hardware sitting here.

To reiterate here, This all used to work in the original meteor it was broken by an ‘upgrade’

I have had file upload working since php 3 in 2005 so I don’t see why this is such a marvel of engineering. It simply was broken by college students wanting a good resume to work at a blue chip. and no one cares.