-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
pass meta to onBeforeUpload #79
Comments
Hi @menelike
|
Thanks for the quick response @dr-dimitru I use this on the server only where context does not contain the meta object. If the meta data does not validate (based on collection references) I want to permit the upload. |
Implemented in dev branch (see: a265fcf). Could you test on your end? |
The solution looks great, the implementation looks valid, now we can predict the document much better. But apart of that, onBeforeUpload is fired twice (tested on master and dev) and to my surprise, only the second time the Current master output:
Current dev output:
I'm not sure if this is a bug from my higher logic. From my point of view this should fire only once. Can you reproduce this? If a new issue is needed here let me know. |
This is expected behaviour, form the docs:
So, on server it will be triggered as many chunks it received.
This is also expected behaviour, as metadata sent only after last chunk of the file is received. We can pass metadata along with each chunk, but this will cause extra bytes sent over the wire - this is not what we want. |
@dr-dimitru sorry for that, totally missed that in the docs. I agree, passing metadata along every chunk isn't the choice in terms of performance. |
@menelike unfortunately not as we currently can't define "first chunk" as any of them may be first - upload is asynchronous. Please see: 5e77d6a |
Understood. Hard to solve. I'll try to patch the source and let you know my results within this day. Thanks for your great support! |
@menelike have a good coding! Let me know your results then, maybe we can workaround this somehow, or improve the package. |
This is a though one. I exposed Meteor.Collection to subclass insert and invalidate the DB insert. Therefore I'm not sure if a PR is welcome. What do you think? https://github.com/risetechnologies/Meteor-Files/commit/8296de3df67b35953a3d12c439ddb83b10f403a3 adds A simple example to get the idea:
As a result, data is always transferred over the wire. If the insert throws an error, the doc won't be saved to the database but isn't deleted from the storage, you would need to manually call Without huge additional efforts I do not see how this could be easily solved. The easiest way would be indeed to add the metadata which might impact performance. a265fcf adds more data than needed, but since I do not see any reliable usability I'd revert that commit. Maybe a flag which controls that |
I believe receiving and checking chunk labeled as Your suggested approach make it more complex, while I'm trying to keep this package with a little moving parts as possible to leave less weak spots which can be broken. I agree with add an ability to pass your own Waiting for your point. |
@dr-dimitru I fully agree with your approach. Your implementation resulted in always sending the meta data. In addition the chunkId needs to be accessible on the receiving server part. See PR. |
|
Sometimes I need to do validations based on user input, e.g. the directory name which the uploaded file should be referenced to. In those cases I need to check permissions on
onBeforeUpload
, but since themeta
obj is not available there is no way to determine the permission.How would this be solved with this lib? Any chance to add meta as additional arg to
onBeforeUpload
call?Thanks in advance.
The text was updated successfully, but these errors were encountered: