Class FileDownloadHandler Abstract
Properties
Protected Readonly directoryArchiver
Protected Readonly fileDownloadCache
Protected Readonly logger
logger: ILogger
Methods
Protected archive
- archive(inputPath: string, outputPath?: string, entries?: string[]): Promise<string>
Parameters
inputPath: string
outputPath: string = ...
Optional entries: string[]
Returns Promise<string>
Protected createTempDir
- createTempDir(downloadId?: string): Promise<string>
Parameters
Returns Promise<string>
Protected download
- download(request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, response: Response<any, Record<string, any>>, downloadInfo: DownloadStorageItem, id: string): Promise<void>
Parameters
request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
response: Response<any, Record<string, any>>
id: string
Returns Promise<void>
Abstract handle
- handle(request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, response: Response<any, Record<string, any>>): Promise<void>
Parameters
request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
response: Response<any, Record<string, any>>
Returns Promise<void>
Protected handleError
- handleError(response: Response<any, Record<string, any>>, reason: string | Error, status?: number): Promise<void>
Parameters
response: Response<any, Record<string, any>>
reason: string | Error
status: number = INTERNAL_SERVER_ERROR
Returns Promise<void>
Protected parseRangeHeader
- parseRangeHeader(range: undefined | string | string[], statSize: number): undefined | { end: number; start: number }
Parameters
range: undefined | string | string[]
statSize: number
Returns undefined | { end: number; start: number }
Protected prepareDownload
- prepareDownload(request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, response: Response<any, Record<string, any>>, options: PrepareDownloadOptions): Promise<void>
Parameters
request: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
response: Response<any, Record<string, any>>
options: PrepareDownloadOptions
Returns Promise<void>
Protected streamDownload
- streamDownload(status: number, response: Response<any, Record<string, any>>, stream: ReadStream, id: string): void
Parameters
status: number
response: Response<any, Record<string, any>>
stream: ReadStream
id: string
Returns void
Prepares the file and the link for download