Skip to content

Commit

Permalink
Use etag to use preview cache
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Nov 8, 2023
1 parent e82f2d7 commit c612eef
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,22 @@ export class FilesStorageController {
@Req() req: Request,
@Res({ passthrough: true }) response: Response,
@Headers('Range') bytesRange?: string
): Promise<StreamableFile> {
): Promise<StreamableFile | void> {
const fileResponse = await this.filesStorageUC.downloadPreview(
currentUser.userId,
params,
previewParams,
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;
Expand Down

0 comments on commit c612eef

Please sign in to comment.