{"action":"created","issue":{"url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/10","labels_url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/10/comments","events_url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/10/events","html_url":"https://github.com/achingbrain/mongoose-crate/issues/10","id":84164496,"number":10,"title":"Custom File Names","user":{"login":"jonstorer","id":104508,"avatar_url":"https://avatars.githubusercontent.com/u/104508?v=3","gravatar_id":"","url":"https://api.github.com/users/jonstorer","html_url":"https://github.com/jonstorer","followers_url":"https://api.github.com/users/jonstorer/followers","following_url":"https://api.github.com/users/jonstorer/following{/other_user}","gists_url":"https://api.github.com/users/jonstorer/gists{/gist_id}","starred_url":"https://api.github.com/users/jonstorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonstorer/subscriptions","organizations_url":"https://api.github.com/users/jonstorer/orgs","repos_url":"https://api.github.com/users/jonstorer/repos","events_url":"https://api.github.com/users/jonstorer/events{/privacy}","received_events_url":"https://api.github.com/users/jonstorer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-02T19:15:25Z","updated_at":"2015-06-02T23:05:21Z","closed_at":null,"body":"Hey, would you accept a pull request to allow filename processing? In short a way to configure the file name to be used for the storage strategies?\r\n\r\nSpecifically, I need a way to put the modelName, fieldName, model's ID, & a time stamp into the file name. The first 3 are for organization & the timestamp is for cache busting.\r\n\r\nsomething like:\r\n`/public/attachments/:modelName/:fieldName/:id-:updated_at-:guid.ext`"},"comment":{"url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/comments/108124442","html_url":"https://github.com/achingbrain/mongoose-crate/issues/10#issuecomment-108124442","issue_url":"https://api.github.com/repos/achingbrain/mongoose-crate/issues/10","id":108124442,"user":{"login":"jonstorer","id":104508,"avatar_url":"https://avatars.githubusercontent.com/u/104508?v=3","gravatar_id":"","url":"https://api.github.com/users/jonstorer","html_url":"https://github.com/jonstorer","followers_url":"https://api.github.com/users/jonstorer/followers","following_url":"https://api.github.com/users/jonstorer/following{/other_user}","gists_url":"https://api.github.com/users/jonstorer/gists{/gist_id}","starred_url":"https://api.github.com/users/jonstorer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonstorer/subscriptions","organizations_url":"https://api.github.com/users/jonstorer/orgs","repos_url":"https://api.github.com/users/jonstorer/repos","events_url":"https://api.github.com/users/jonstorer/events{/privacy}","received_events_url":"https://api.github.com/users/jonstorer/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T23:05:21Z","updated_at":"2015-06-02T23:05:21Z","body":"I could.\r\n\r\nHowever, the use case I'm solving for is S3 or an S3 like strategy. I'm less worried about LocalFS.\r\n\r\nI want to be able to send the asset's url to the client as part of a JSON API's payload. Then have the client to fetch the asset directly. I also want the client to be able to cache assets on device. Which is why I'd like to the url to be representative of the asset it's representing.\r\n\r\nI do realize that crate will take the name from the file, and most likely the file will be a tmp file & have a tmp name, however, I can't rely on server to create unique temporary filenames forever. At some point, the file name will repeat and it will overwrite something.\r\n\r\nIf I could change the storage path at write time, then I could organize the files, include unique information, and cache busting details such as time stamps.\r\n\r\nIn a real world use case: I had a data snafu where documents lost reference to their assets on S3. I was able to reconnect the asset and document because the storage location included the model name, property name, & doc id.  That was using mongoose-attachment. I'd like to switch to your library because it does not rely on imagemagick. Which means I can have non-image attachments.\r\n\r\nI realize, some of this request is vanity. I'd _really_ like to be able to organize the files on S3 is some sane manner. **However**, the part that isn't, is rooted in the real possibility that the files names could collide. And recovering data in case of emergency _is_ possible.\r\n\r\nIf an asset's path is a combination of model, property, id, etc... the chance of collision is extremely low.\r\n\r\n---\r\n\r\nAbout your solution for LocalFS, I'd prefer not to have to retrieve the document from mongo in order to return the asset. I'd rather just expose the asset url to the client. Less work for me."}}