Rocket.Chat supports various file storage types to manage file uploads. Each system has its strengths and limitations. This guide outlines some of these options and provides recommendations based on scalability and production requirements. To configure the file upload storage type in your workspace, visit File Upload.
Amazon S3 and Google Cloud Storage are the recommended options for file upload in Rocket.Chat.
GridFS
GridFS is a MongoDB specification for storing and retrieving large files such as images, audio, and video. While it functions like a file system, GridFS stores its data within MongoDB collections. It is designed to handle files that exceed MongoDB's document size limit of 16MB.
GridFS divides a file into smaller chunks and stores each chunk of data in a separate document, each with a maximum size of 255KB. It uses two collections to store files:
fs.files
stores the file’s metadatafs.chunks
stores the binary chunks
Visit the GridFS documentation to learn more.
By default, GridFS is used in Rocket.Chat for file storage because MongoDB offers this functionality with zero configuration. However, it is not recommended for production environments due to the high load it places on the database. GridFS can only be suitable if:
A retention policy is in place to manage file storage.
You are storing only a small number of lightweight files each week.
File System
The File System stores uploaded files directly on the local storage of the server running the Rocket.Chat instance. It is simple to configure and works well for small-scale, single-server deployments. Files are stored in a designated folder on the server's file system, and Rocket.Chat retrieves them directly as needed.
Configuring File System storage
To use File System as the storage type, navigate to Workspace > Administration > Settings > File Upload and continue with the following steps :
Go to General and select File System as the Storage Type.
Navigate to FileSystem and specify a valid System Path on the server where files will be uploaded. For example, setting the path to
/uploads
will save files in anuploads
directory at the root of your server.Click Save Changes and restart the Rocket.Chat server. Uploaded files will now be saved to the specified system path.
Accessing the Rocket.Chat server to confirm the uploaded files varies based on your deployment method:
For Docker deployments, access the Rocket.Chat container with
docker exec -it <container-name> sh
.
When scaling Rocket.Chat to multiple servers, the File System becomes challenging:
The file storage directory must be accessible to all Rocket.Chat servers. This requires setting up shared storage solutions such as Network File System (NFS).
Managing shared storage introduces additional configuration and infrastructure overhead.
FileSystem is recommended only when you are running a single Rocket.Chat instance.