Meteor-Files: this.userId is not always available onBeforeUpload
I am trying to validate the user in onBeforeUpload:
onBeforeUpload: function (file) {
console.log(this.userId);
}
But on the server it outputs 3 lines for a single upload:
I20160830-12:46:55.587(2)? undefined
I20160830-12:46:55.820(2)? LSmRXxxkSs9RrPfN4
I20160830-12:46:55.832(2)? LSmRXxxkSs9RrPfN4
Two questions, one is why it calls three times? second is why the first time this.userId is not defined?
Thanks.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (11 by maintainers)
Commits related to this issue
- Fix #207 - Fix availability of `this.userId` in `onBeforeUpload` hook - `this.userId` now always `null` if user not logged in, previously sometimes it might be `undefined` — committed to veliovgroup/Meteor-Files by dr-dimitru 8 years ago
- Merge pull request #209 from VeliovGroup/dev v1.7.2 - Fix #207 - Fix availability of `this.userId` in `onBeforeUpload` hook - `this.userId` now always `null` if user not logged in, previously ... — committed to veliovgroup/Meteor-Files by dr-dimitru 8 years ago
@dr-dimitru It worked for me, thanks.