1 | import { Request as ERequest, Response as EResponse } from "express";
|
2 | import AsyncResponse from "./async.response";
|
3 |
|
4 |
|
5 |
|
6 | export interface FileOptions {
|
7 | width: number;
|
8 | height?: number;
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | export default class FileResponse extends AsyncResponse {
|
14 | private readonly path;
|
15 | private _contentType?;
|
16 | private _fileName;
|
17 | private _options?;
|
18 | constructor(path: string);
|
19 | /**
|
20 | * Set the content type of the response.
|
21 | * @param value the content type
|
22 | */
|
23 | set contentType(value: string);
|
24 | /**
|
25 | * Set the name of the file to download
|
26 | * @param value the name of the file
|
27 | */
|
28 | set fileName(value: string);
|
29 | /**
|
30 | * Set the file options, to correctly generate the response.
|
31 | * @param value the FileOptions
|
32 | */
|
33 | set options(value: FileOptions);
|
34 | private download;
|
35 | /**
|
36 | * Generation of the response.
|
37 | * This method can eventually perform some transformation on output if a
|
38 | * FileOptions was specified.
|
39 | */
|
40 | asyncResponse(_: ERequest, res: EResponse): Promise<void>;
|
41 | }
|