Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mcieslakcc opened this issue Nov 6, 2024 · 0 comments

Comments

@mcieslakcc
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant