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?

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