recommendations-for-file-upload.md 2.05 KB
Newer Older
1
2
3
4
# Recommendations for File Upload

## GridFS

5
GridFS is the MongoDB specification for storing and retrieving large files such as images, audio files, video files, etc. It is a kind of a file system to store files but its data is stored within MongoDB collections. GridFS has the capability to store files even greater than its document size limit of 16MB.
6
7
8
9
10

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 serves as a parent document. The **files\_id** field in the fs.chunks document links the chunk to its parent.

11
Though GridFS is used in rocket.chat for file storage because MongoDB offers this functionality with zero configuration but GridFS 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.
12
13

{% hint style="info" %}
14
**GridFS** is only sustainable if you are using Retention Policy and only storing a small number of files per week which are not hefty but it is not recommended by us because it is not scalable. 
15
16
17
18
{% endhint %}

## FileSystem

19
It stores the files on the FileSystem of the server where your 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.
20

21
If you want to have two separate virtual/physical servers you will somehow have to share the folder too where your files are stored using for example NFS. It will require a lot of configurations.
22
23

{% hint style="info" %}
24
We recommend **FileSystem** only when you are using a single virtual/physical server.
25
26
{% endhint %}

27
{% hint style="info" %}
28
What we suggest as the best option for the file upload system are **Amazon** **S3** and **Google Cloud Storage**.
29
{% endhint %}
30