wip
This commit is contained in:
parent
12afc294f7
commit
f69e57385b
|
@ -19,7 +19,10 @@ import type { Response } from 'undici';
|
||||||
const pipeline = util.promisify(stream.pipeline);
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
type NonNullBodyResponse = Response & { body: ReadableStream };
|
export type NonNullBodyResponse = Response & {
|
||||||
|
body: ReadableStream;
|
||||||
|
clone: () => NonNullBodyResponse;
|
||||||
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DownloadService {
|
export class DownloadService {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { createTemp } from '@/misc/create-temp.js';
|
||||||
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
||||||
import { StatusError } from '@/misc/status-error.js';
|
import { StatusError } from '@/misc/status-error.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
import { DownloadService } from '@/core/DownloadService.js';
|
import { DownloadService, NonNullBodyResponse } from '@/core/DownloadService.js';
|
||||||
import { ImageProcessingService, webpDefault } from '@/core/ImageProcessingService.js';
|
import { ImageProcessingService, webpDefault } from '@/core/ImageProcessingService.js';
|
||||||
import { VideoProcessingService } from '@/core/VideoProcessingService.js';
|
import { VideoProcessingService } from '@/core/VideoProcessingService.js';
|
||||||
import { InternalStorageService } from '@/core/InternalStorageService.js';
|
import { InternalStorageService } from '@/core/InternalStorageService.js';
|
||||||
|
@ -109,9 +109,9 @@ export class FileServerService {
|
||||||
if (!file.storedInternal) {
|
if (!file.storedInternal) {
|
||||||
if (file.isLink && file.uri) { // 期限切れリモートファイル
|
if (file.isLink && file.uri) { // 期限切れリモートファイル
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
const response = await this.downloadService.fetchUrl(file.uri);;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
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);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { isMimeImage } from '@/misc/is-mime-image.js';
|
import { isMimeImage } from '@/misc/is-mime-image.js';
|
||||||
import { createTemp } from '@/misc/create-temp.js';
|
import { createTemp } from '@/misc/create-temp.js';
|
||||||
import { DownloadService } from '@/core/DownloadService.js';
|
import { DownloadService, NonNullBodyResponse } from '@/core/DownloadService.js';
|
||||||
import { IImageStreamable, ImageProcessingService, webpDefault } from '@/core/ImageProcessingService.js';
|
import { IImageStreamable, ImageProcessingService, webpDefault } from '@/core/ImageProcessingService.js';
|
||||||
import type { IImage } from '@/core/ImageProcessingService.js';
|
import type { IImage } from '@/core/ImageProcessingService.js';
|
||||||
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
|
||||||
|
@ -75,9 +75,9 @@ export class MediaProxyServerService {
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
const response = await this.downloadService.fetchUrl(url);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
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