wip
This commit is contained in:
parent
cbf7c296df
commit
b83b2f5d01
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue