refactor
This commit is contained in:
parent
510817aad4
commit
d57f5d26a5
|
@ -79,7 +79,7 @@ export class DownloadService {
|
||||||
@bindThis
|
@bindThis
|
||||||
public async pipeRequestToFile(_response: Response, path: string): Promise<void> {
|
public async pipeRequestToFile(_response: Response, path: string): Promise<void> {
|
||||||
const response = _response.clone();
|
const response = _response.clone();
|
||||||
if (response.body === null) {
|
if (response.body == null) {
|
||||||
throw new StatusError('No body', 400, 'No body');
|
throw new StatusError('No body', 400, 'No body');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,7 @@ export class FileServerService {
|
||||||
if (file.isLink && file.uri) { // 期限切れリモートファイル
|
if (file.isLink && file.uri) { // 期限切れリモートファイル
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
try {
|
try {
|
||||||
const _response = await this.downloadService.fetchUrl(file.uri);;
|
const response = await this.downloadService.fetchUrl(file.uri);
|
||||||
const response = _response.clone() as NonNullBodyResponse;
|
|
||||||
const fileSaving = this.downloadService.pipeRequestToFile(response, path);
|
const fileSaving = this.downloadService.pipeRequestToFile(response, path);
|
||||||
|
|
||||||
let { mime, ext } = await this.fileInfoService.detectRequestType(response);
|
let { mime, ext } = await this.fileInfoService.detectRequestType(response);
|
||||||
|
|
|
@ -74,8 +74,7 @@ export class MediaProxyServerService {
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
try {
|
try {
|
||||||
const _response = await this.downloadService.fetchUrl(url);
|
const response = await this.downloadService.fetchUrl(url);
|
||||||
const response = _response.clone() as NonNullBodyResponse;
|
|
||||||
const fileSaving = this.downloadService.pipeRequestToFile(response, path);
|
const fileSaving = this.downloadService.pipeRequestToFile(response, path);
|
||||||
|
|
||||||
let { mime, ext } = await this.fileInfoService.detectRequestType(response);
|
let { mime, ext } = await this.fileInfoService.detectRequestType(response);
|
||||||
|
|
Loading…
Reference in New Issue