Skip to content

[3.0.0-beta.6] fileObj upload end attaching custom properties e.g error? #893

Open
@mcieslakcc

Description

@mcieslakcc

I'm having an issue:

In afterUpload event I validate using mmmagic if file extension is correct if not I remove file

  ImagesCollection.on('afterUpload', async file => {
    const returnedFile = file;
    await validateUploadedFile(file)
      .catch(async error => {
        await ImagesCollection.removeAsync(file._id);
        returnedFile.error = error.message;
      });

    return returnedFile;
  });

but on frontend in
uploader.on('end', (error, fileObj) => {
fileObj does not contain error property

it was working in previous releases(before 3.0) when we were using Future

ImagesCollection.on('afterUpload', function (file) {
   const returnedFile = file;
   const futureResult = new Future();
   validateUploadedFile(file)
     .then(() => {
       futureResult.return(file);
     })
     .catch(error => {
       this.remove(file._id);
       returnedFile.error = error.message;
       futureResult.return(file);
     });
   futureResult.wait();
 });

Do you have any suggestion how to fix/implement this in 3.0.0-beta.6 version?

Activity

dr-dimitru

dr-dimitru commented on Mar 24, 2025

@dr-dimitru
Member

@mcieslakcc v3.0.0-beta.7 is out, please give it a try. If "event" won't work use onAfterUpload function as option passed to new FilesCollection constructor. Let me know if it works for you

dr-dimitru

dr-dimitru commented on Mar 26, 2025

@dr-dimitru
Member

@mcieslakcc please try ostrio:files@3.0.0-rc.2 a lot of things fixed and improved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [3.0.0-beta.6] fileObj upload end attaching custom properties e.g error? · Issue #893 · veliovgroup/Meteor-Files