Recommendations for File Upload
    • Dark
      Light
    • PDF

    Recommendations for File Upload

    • Dark
      Light
    • PDF

    Article summary

    GridFS

    GridFS is the MongoDB specification for storing and retrieving large files such as images, audio, videos, etc. It is a kind of file system that stores files, but its data is stored within MongoDB collections. GridFS can store files that are even larger than its document size limit of 16MB.

    GridFS divides a file into chunks and stores each chunk of data in a separate document, each of maximum size 255k.

    GridFS, by default, uses two collections, fs.files and fs.chunks, to store the file's metadata and the chunks. Each chunk is identified by its unique _id ObjectId field. The fs.files serve as a parent document. The files_id field in the fs.chunks document links the chunk to its parent.

    Though GridFS is used in Rocket.Chat for file storage because MongoDB offers this functionality with zero configuration; it is not recommended for day-to-day file storage needs in a production environment because it puts an immense amount of load on the database.

    GridFS is only sustainable if you are using Retention Policy and only storing a small number of files per week, which are not hefty. However, we do not recommend it because it is not scalable.

    FileSystem

    It stores the files on the FileSystem of the server where the Rocket.Chat instance is running. It is a good option, but the problem arises when you start to scale. Because if you decide to have multiple Rocket.Chat servers to support a larger number of users, the FileSystem needs to be shared between all the Rocket.Chat servers.

    If you want to have two separate virtual/physical servers, you will have to share the folder where your files are stored, such as NFS. This will require many configurations.

    We suggest FileSystem only when you are running a single Rocket.Chat instance.

    What we recommend as the best option for the file upload system are Amazon S3 and Google Cloud Storage.


    Was this article helpful?

    What's Next
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence