Skip to content

Commit

Permalink
Fix for onInitiateUpload
Browse files Browse the repository at this point in the history
 - Call `onInitiateUpload` even if `onBeforeUpload` is not defined, see
[this
comment](#208 (comment)
ment-301208873), thanks to @DrkCoater
  • Loading branch information
dr-dimitru committed May 18, 2017
1 parent 50f48ef commit 9e0b400
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion files.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ class FilesCollection
}, {
chunkId: opts.chunkId
userId: result.userId
user: -> if Meteor.users then Meteor.users.findOne(result.userId) else null
user: -> if (Meteor.users && result.userId) then Meteor.users.findOne(result.userId) else null
eof: opts.eof
}
isUploadAllowed = @onBeforeUpload.call ctx, result
Expand All @@ -1082,6 +1082,16 @@ class FilesCollection
else
if opts.___s is true and @onInitiateUpload and _.isFunction @onInitiateUpload
@onInitiateUpload.call ctx, result
else if opts.___s is true and @onInitiateUpload and _.isFunction @onInitiateUpload
ctx = _.extend {
file: opts.file
}, {
chunkId: opts.chunkId
userId: result.userId
user: -> if (Meteor.users && result.userId) then Meteor.users.findOne(result.userId) else null
eof: opts.eof
}
@onInitiateUpload.call ctx, result

return {result, opts}
else undefined
Expand Down

0 comments on commit 9e0b400

Please # to comment.