Store and serve pdf documents

Good Morning. I need to store and save pdf and doc documents. Which is the best option? Thank you

Good Morning @francisco_jose, welcome to MongoDB forum.

In MongoDB, you use GridFS for storing files larger than 16 MB.

If the files (i.e., each of them) to be stored are within the 16 MB limit of BSON document size, then you can store the files within a collection’s document as a field of type Binary Data (binData).

1 Like

Thanks for quick reply. Still separate the data into two custer? One for data related to pdf and the other for pdf? Best regards

What are you considering - GridFS or within a document? What is the maximum size of the PDF documents?

In case of GridFS, the file and its information is stored in two collections (the files and chunks collections). The files stores the file’s metadata (information about the file like, id, length / size, filename, content type, etc.) and the chunks stores the actual file data.

In case of a document as a file store, you can have additional fields specifying the file name, description etc., that is within the same document of the collection.