This commit is contained in:
tamaina 2023-01-24 00:33:16 +00:00
parent cbf7c296df
commit b83b2f5d01
1 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import { FileInfoService, TYPE_SVG } from '@/core/FileInfoService.js';
import { LoggerService } from '@/core/LoggerService.js'; import { LoggerService } from '@/core/LoggerService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify'; import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify';
import { Readable, pipeline } from 'node:stream'; import { PassThrough, Readable, pipeline } from 'node:stream';
import { isMimeImage } from '@/misc/is-mime-image.js'; import { isMimeImage } from '@/misc/is-mime-image.js';
import sharp from 'sharp'; import sharp from 'sharp';
@ -118,7 +118,7 @@ export class FileServerService {
private async sendDriveFile(request: FastifyRequest<{ Params: { key: string; } }>, reply: FastifyReply) { private async sendDriveFile(request: FastifyRequest<{ Params: { key: string; } }>, reply: FastifyReply) {
const key = request.params.key; const key = request.params.key;
const file = await this.getFileFromKey(key).then(); const file = await this.getFileFromKey(key).then();
console.log(file);
if (file === '404') { if (file === '404') {
reply.code(404); reply.code(404);
reply.header('Cache-Control', 'max-age=86400'); reply.header('Cache-Control', 'max-age=86400');
@ -208,7 +208,7 @@ export class FileServerService {
// Create temp file // Create temp file
const file = await this.getStreamAndTypeFromUrl(url); const file = await this.getStreamAndTypeFromUrl(url);
console.log(file)
if (file === '404') { if (file === '404') {
reply.code(404); reply.code(404);
reply.header('Cache-Control', 'max-age=86400'); reply.header('Cache-Control', 'max-age=86400');
@ -356,7 +356,7 @@ export class FileServerService {
return { return {
state: 'remote', state: 'remote',
stream: Readable.fromWeb(response.body), stream: Readable.fromWeb(response.body).pipe(new PassThrough()),
mime, ext, mime, ext,
path, cleanup, path, cleanup,
fileSaving, fileSaving,