Reza S
Reza S

Reputation: 9748

MongoDB+GridFS on Symfony2

I need to store some files in my Mongo database and came across these two questions:

  1. I do not care about the names of these files, I'll be addressing them by their unique mongo id. the Mongo db driver by default adds the filename as it is adding the content of it to the database and I believe it creates an index on it as well. Is there a way to tell it don't bother about the name of the file?

  2. If all I'm adding to the database are images of type JPEG (same content type), do I gain any advantages by using the Symfony's mongo ODM as described here

Wasn't sure if I needed to create two separate questions since they are quite different questions, but answers or ideas about either of these questions will be appreciated.

Upvotes: 0

Views: 816

Answers (1)

Dennis Coorn
Dennis Coorn

Reputation: 36

Hereby my ideas regarding your questions:

  1. I think there isn't a way to tell the MongoDB driver to ignore the filename when storing a file to GridFS. I just run a short test and the filename will always be stored within the document. What I did find out is that there will be no index created for the filename by default. This can be checked by running 'db.Upload.files.getIndexes()' in the mongo shell to see which indexes are created on the collection.

  2. I don't think there is a limitation on what type of files or even file sizes you're storing. Although GridFS is a storage specification for large objects it look likes there isn't any restrictions to use it for, lets say, many small JPEG files. A small example of an advantage in using it with Symfony and Mongo ODM will be that it's very easy to add ACL functionality when requesting an uploaded file.

Hopefully this will answer your questions.

Upvotes: 2

Related Questions