Commit af7e740b by Archer Committed by GitHub

fix: clamp uploaded file access url expiration (#7289)

parent 69120fc8
...@@ -16,7 +16,7 @@ import { S3ErrEnum } from '@fastgpt/global/common/error/code/s3'; ...@@ -16,7 +16,7 @@ import { S3ErrEnum } from '@fastgpt/global/common/error/code/s3';
import { createUploadConstraints } from '../utils/uploadConstraints'; import { createUploadConstraints } from '../utils/uploadConstraints';
import path from 'node:path'; import path from 'node:path';
import { MongoS3TTL } from '../models/ttl'; import { MongoS3TTL } from '../models/ttl';
import { addHours, addMinutes, differenceInSeconds } from 'date-fns'; import { addHours, addMinutes, differenceInHours, differenceInSeconds } from 'date-fns';
import { getLogger, LogCategories } from '../../logger'; import { getLogger, LogCategories } from '../../logger';
import { addS3DelJob } from '../queue/delete'; import { addS3DelJob } from '../queue/delete';
import { type UploadFileByBufferParams, UploadFileByBodySchema } from '../contracts/type'; import { type UploadFileByBufferParams, UploadFileByBodySchema } from '../contracts/type';
...@@ -314,7 +314,7 @@ export class S3BaseBucket { ...@@ -314,7 +314,7 @@ export class S3BaseBucket {
key, key,
accessUrl: await this.createExternalUrl({ accessUrl: await this.createExternalUrl({
key, key,
expiredHours: 2 expiredHours: Math.max(1, differenceInHours(expiredTime, new Date()))
}) })
}; };
} }
......
Subproject commit f104fb8433feea4719d3ec742bece0aa0b91b3d3 Subproject commit 2900ffe15207cea0755c6d60dd5752ee41c261e6
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment