Merge branch 'serve-stream' into proxy-res-file
This commit is contained in:
commit
cf44aa1d57
3 changed files with 16 additions and 34 deletions
|
|
@ -63,7 +63,6 @@
|
|||
"file-type": "18.2.0",
|
||||
"fluent-ffmpeg": "2.1.2",
|
||||
"form-data": "^4.0.0",
|
||||
"got": "12.5.3",
|
||||
"hpagent": "1.2.0",
|
||||
"ioredis": "4.28.5",
|
||||
"ip-cidr": "3.0.11",
|
||||
|
|
@ -182,6 +181,7 @@
|
|||
"eslint": "8.32.0",
|
||||
"eslint-plugin-import": "2.27.5",
|
||||
"execa": "6.1.0",
|
||||
"got": "12.5.3",
|
||||
"jest": "29.3.1",
|
||||
"jest-mock": "^29.3.1",
|
||||
"node-fetch": "3.3.0"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as util from 'node:util';
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import IPCIDR from 'ip-cidr';
|
||||
import PrivateIp from 'private-ip';
|
||||
import got, * as Got from 'got';
|
||||
import chalk from 'chalk';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { Config } from '@/config.js';
|
||||
|
|
@ -83,16 +82,8 @@ export class DownloadService {
|
|||
throw new StatusError('No body', 400, 'No body');
|
||||
}
|
||||
|
||||
try {
|
||||
this.logger.info(`Saving File to ${chalk.cyanBright(path)} from downloading ...`);
|
||||
await pipeline(stream.Readable.fromWeb(response.body), fs.createWriteStream(path));
|
||||
} catch (e) {
|
||||
if (e instanceof Got.HTTPError) {
|
||||
throw new StatusError(`${e.response.statusCode} ${e.response.statusMessage}`, e.response.statusCode, e.response.statusMessage);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
this.logger.info(`Saving File to ${chalk.cyanBright(path)} from downloading ...`);
|
||||
await pipeline(stream.Readable.fromWeb(response.body), fs.createWriteStream(path));
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue