mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
4.6.4-alpha (#582)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { UploadImgProps } from '@fastgpt/global/common/file/api';
|
||||
import { imageBaseUrl } from './constant';
|
||||
import { MongoImage } from './schema';
|
||||
|
||||
@@ -9,11 +10,10 @@ export const maxImgSize = 1024 * 1024 * 12;
|
||||
export async function uploadMongoImg({
|
||||
base64Img,
|
||||
teamId,
|
||||
expiredTime
|
||||
}: {
|
||||
base64Img: string;
|
||||
expiredTime,
|
||||
metadata
|
||||
}: UploadImgProps & {
|
||||
teamId: string;
|
||||
expiredTime?: Date;
|
||||
}) {
|
||||
if (base64Img.length > maxImgSize) {
|
||||
return Promise.reject('Image too large');
|
||||
@@ -24,7 +24,8 @@ export async function uploadMongoImg({
|
||||
const { _id } = await MongoImage.create({
|
||||
teamId,
|
||||
binary: Buffer.from(base64Data, 'base64'),
|
||||
expiredTime
|
||||
expiredTime: expiredTime,
|
||||
metadata
|
||||
});
|
||||
|
||||
return getMongoImgUrl(String(_id));
|
||||
@@ -37,3 +38,9 @@ export async function readMongoImg({ id }: { id: string }) {
|
||||
}
|
||||
return data?.binary;
|
||||
}
|
||||
|
||||
export async function delImgByFileIdList(fileIds: string[]) {
|
||||
return MongoImage.deleteMany({
|
||||
'metadata.fileId': { $in: fileIds.map((item) => String(item)) }
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user