Skip to content

Avoid Random.id() on addFile  #299

@menelike

Description

@menelike

I think its reasonable to switch from Random.id() to _id as a part of the insert callback.
https://github.com/VeliovGroup/Meteor-Files/blob/master/files.coffee#L1412

Moreover, it should be noted that fileRef in the callback of addFile is not the inserted document like described in https://github.com/VeliovGroup/Meteor-Files/blob/dd59d886db69e8d74db3ebb5e1c7bde74f0b64c9/docs/addFile.md

callback {Function} - Triggered after new record is added to Collection. With error, and fileRef, where fileRef is a new record from DB

Instead it's a predicted document, as data is not fetched from the database after insert. This may also fail on the next calls like proceedAfterUpload. We subclass collection.insert and add some extra fields like timestamps, in those cases we findOne(fileRef._id) to fetch the real document) and pass it to proceedAfterUpload on callback.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions