Handeling FileSystem Uploads

Description

Hi there, i’m trying to figure out how files are handled when changing the upload type to FileSystem.

  • First, how are the files stored in the file system? I can not see the original files in the uploads folder, just documents with random numbers and no file name extension. Why is this. Are the files converted into some sort of binary code?
  • Second, how would i make sure the files are backed up when running the snap run rocketchat-server.backupdb script? It seems to me the backup only contains the database itself, but not the files
    I appreciate any help with this!

Server Setup Information

  • Version of Rocket.Chat Server: 3.18.3

Hi!

When you upload a file, and you have File System as the storage, instead of GridFS, the file is uploaded into the configured path with the ID of the item created at the collection rocketchat_uploads, like so:

{
	"_id": "CsxPGBLeXtzW9n6Qw",
	"name": "Captura de tela de 2021-11-20 22-15-24.png",
	"size": 114125,
	"type": "image/png",
	"rid": "6a4DvbexK63WycG5n",
	"userId": "fKCApZExQec7JRqnt",
	"store": "FileSystem:Uploads",
	"identify": {
		"format": "png",
		"size": {
			"width": 1920,
			"height": 1080
		}
	},
	"complete": true,
	"etag": "imqHyyaXyAgHsFxYA",
	"path": "/ufs/FileSystem:Uploads/CsxPGBLeXtzW9n6Qw/Captura%20de%20tela%20de%202021-11-20%2022-15-24.png",
	"progress": 1,
	"token": "6A9Bf86A09",
	"uploadedAt": {
		"$date": "2021-12-20T12:24:19.742Z"
	},
	"uploading": false,
	"url": "http://localhost:3000/ufs/FileSystem:Uploads/CsxPGBLeXtzW9n6Qw/Captura%20de%20tela%20de%202021-11-20%2022-15-24.png",
	"_updatedAt": {
		"$date": "2021-12-20T12:24:19.755Z"
	},
	"typeGroup": "image"
}

So, the ID (CsxPGBLeXtzW9n6Qw) will have a reference for the file itself, and the name should be the filename. CsxPGBLeXtzW9n6Qw is what I will find in my /app/uploads folder, Or whatever you configured at Admin > File Upload

When you run the backupdb snap command, it will backup only the database.

You can backup the files just by copying them. The database will hold this reference for you.

However, if you use Gridfs, the files are kept with mongodb :slight_smile:

Thanks, this is a great explanation. Very helpful and much appreciated.

1 Like