Closed make-github-pseudonymous-again closed 1 year ago
Hello @make-github-pseudonymous-again,
onBeforeUpload
is meant for this purpose. As stated in the docs after the first chunk is received. Intermediate collection used to store during upload
Oh, great! How does one modify the metadata at this stage? Just by modifying the file object? Or do we need to make a query against this intermediate collection? Could onInitiateUpload
be used instead? If using onBeforeUpload
, should I check for this.chunkId == -1 && !this.eof
to only act once?
@make-github-pseudonymous-again on this stage it's possible abort or continue upload, Altering meta-data should happen in onAfterUpload
I understand. Is there a plan to make this possible in the future? To avoid having yet-another extra layer of "the upload is there but it's not ready for use yet".
My point is that the upload action finishes before it's metadata is updated in onAfterUpload
, so one would have to add extra logic to be synchronized with that event.
@make-github-pseudonymous-again
the upload is there but it's not ready for use yet
Not sure if I've got this one correctly. But it's how it's usually done:
OK. And you don't think this library should allow to abstract those two steps into a single one?
My solution without changing this library is to add an extra flag to each document that says whether certain things in onAfterUpload
have run. Then I have to abstract away every Uploads.insert
call to wait for this flag to be set, and every publication or method that involves those documents needs to filter documents based on this flag.
OK. And you don't think this library should allow to abstract those two steps into a single one?
No, that would be unnecessary overhead. This lib allows you to control these things.
My solution without changing this library is to add an extra flag to each document that says whether certain things in
onAfterUpload
have run. Then I have to abstract away everyUploads.insert
call to wait for this flag to be set, and every publication or method that involves those documents needs to filter documents based on this flag.
@make-github-pseudonymous-again sounds correct, we were using one of two options:
OK. Feel free to close!
The API allows a user to send any arbitrary metadata together with the uploaded file. Is it possible to check/validate/modify this metadata on the server before it is inserted in the Mongo collection?
It seems when
onBeforeUpload
is called the file already has an_id
so is it already inserted at that point?An alternative is to use
onAfterUpload
, but that is too late, and will result in one insertion, and one update, instead of just one insertion.