Bioshox/Thundergrid — pull request #5 by jmikola (2012-06-26 23:51:38+00:00)
Title: Refactoring

Some changes:

* Extend a common controller class instead of the Mongo connection, as that isn't recommended.
* Use GridFS alone as a data store. It can store our metadata and perform lookups by the ObjectId already assigned to a file.
* Cleaned up HTML (replaced single quotes, added tags to the index page)
* Infer the image type of the file instead of trusting the upload metadata, which isn't reliable. Fallback to a generic type (if the user uploads an arbitrary, binary file).

One improvement I had in mind, but could not implement, is outputting the file using [MongoGridFSFile::getResource()](http://www.php.net/manual/en/mongogridfsfile.getresource.php). Unfortunately, this method doesn't appear to be implemented in the PECL driver I had installed. I'll speak to Derick about it, but making use of this would allow the download action to be a bit more efficient with memory, as we could copy chunks of data from the file stream to the output stream instead of loading all of its bytes into memory.