vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

Suggestion: Post-read hook #124

Open rune-bk opened 8 years ago

rune-bk commented 8 years ago

Great package! Keep up the good work!

I just have a small suggestion. Support for temporary/N-time-access files. It can in theory be accomplished in allow-read, but only if it's the second time it's being accessed.

I'd like to return the file, then wipe the file + collection document from the system. Specifically for generated files (excel reports etc etc)

Doing so in allow-deny upon first access would delete it before it's being returned.

Can it be accomplished in some way using the custom handler?

vsivsi commented 8 years ago

You can do this by defining a custom handler for GET requests on some route. https://github.com/vsivsi/meteor-file-collection#configuring-http-methods

You could just reuse the default code, and then add whatever removal logic you want following a successful response. https://github.com/vsivsi/meteor-file-collection/blob/master/src/http_access_server.coffee#L135

I'm not inclined to add this type of feature to the package directly because it adds complexity and API surface to test and maintain, but based on the above, I think the flexibility is there to implement the functionality you desire in your own code without too much trouble.