willhuang85/skipper-gridfs — pull request #9 by aggied (2014-11-28 05:29:42+00:00)
Title: support storing custom metadata/content_type & mongodb connection URIs without buckets

The changes I have made here are quick improvements that allow for 3 new features:

1- allow for inputs from the post request to be stored as metadata with the file in GridFS
2 - provide an option to store the actual content-type sent with the file in GridFS rather than the default binary/octet-stream.
3 - mongodb uris that don't contain buckets

My needs required that I store the html form inputs that come with the file upload as `metadata` on the file in GridFS. Essentially, users are uploading files with additional properties like image caption and I preferred to store that in the metadata of the default fs. I also wanted the option to have the actual file content-type stored as `contentType` in GridFS.

The current regex and url parsing in the `_URIisValid` and `_setURI` does not support mongodb uris that don't have bucket. `mongodb://username:password@localhost:27107/databasename.bucket` works, whereas `mongodb://username:password@localhost:27107/databasename` doesn't. My changes at lines 277-306 are a very quick solution to that. Preferably it gets cleaned up at some point.

I'm assuming someone else out there is looking for this solution so I thought I'd share.