veliovgroup / Meteor-Files

🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.
https://packosphere.com/ostrio/files
BSD 3-Clause "New" or "Revised" License
1.11k stars 166 forks source link

onAfterUpload not throwing error in uploader.on('end') #878

Closed guillaumemach closed 11 months ago

guillaumemach commented 11 months ago

Hi all,

I'm having an issue:

We are trying to perform checks in the settings.onAfterUpload callback (if I understood correctly it is only server side). If one check fails we want to return an error, and catch it in the "end" event (client side).

Is there a way to do this ? Is this a bug ?

Meteor@2.12 ostrio:files@2.3.3

Thanks a lot for your help,

Guillaume

dr-dimitru commented 11 months ago

Hello @guillaumemach onAfterUpload is purely async and happens after upload fully recieved on the server. I'd suggest to look for other hooks in order to complete your goals, like onBeforeUpload which can get used on the client as well

guillaumemach commented 11 months ago

Hello @dr-dimitru ,

Thanks for your reply. Which hook would you recommend to perform checks on the uplaoded file ? We tried onUploaded, but same problem nothing returns to the client side events (or maybe we did something wrong).

Bests

dr-dimitru commented 11 months ago

@guillaumemach for fully uploaded file the only option is onAfterUpload, just don't expect events on the client, I'm suggesting to:

  1. Add verified or similar option to meta
  2. subscribe on uploaded file for changes in meta.verified
  3. Check file in onAfterUpload and update meta.verified
  4. Perform action based on changes in meta.verified
guillaumemach commented 11 months ago

@dr-dimitru ok thanks a lot.

dr-dimitru commented 11 months ago

Feel free to reopen it in case if the issue is still persists on your end.