diff --git a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts index 736d69e3e29..11232f3ebf2 100644 --- a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts +++ b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts @@ -135,7 +135,7 @@ export class FilesStorageController { @Req() req: Request, @Res({ passthrough: true }) response: Response, @Headers('Range') bytesRange?: string - ): Promise { + ): Promise { const fileResponse = await this.filesStorageUC.downloadPreview( currentUser.userId, params, @@ -143,6 +143,14 @@ export class FilesStorageController { bytesRange ); + if (req.headers['if-none-match'] === fileResponse.etag) { + response.status(304); + + return undefined; + } + + response.set({ ETag: fileResponse.etag }); + const streamableFile = this.streamFileToClient(req, fileResponse, response, bytesRange); return streamableFile;