mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 11:00:55 +03:00
Feat/add multer s3 (#3854)
* add multer s3 * add types multer s3 * update multer s3 implementation * Revert "update multer s3 implementation" This reverts commit 9a25bf57a93f77074bdb084921f0591dbe0b44e1. * update storage utils * update multer storage type on routes * revert getMulterStorage * revert getMulterStorage * update getmulterstorage * update getmulterstorage * update getmulterstorage
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import { Request } from 'express'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { cloneDeep, omit } from 'lodash'
|
||||
import { ICommonObject, IMessage, addArrayFilesToStorage, mapMimeTypeToInputField, mapExtToInputField } from 'flowise-components'
|
||||
import {
|
||||
ICommonObject,
|
||||
IMessage,
|
||||
addArrayFilesToStorage,
|
||||
mapMimeTypeToInputField,
|
||||
mapExtToInputField,
|
||||
getFileFromUpload,
|
||||
removeSpecificFileFromUpload
|
||||
} from 'flowise-components'
|
||||
import logger from '../utils/logger'
|
||||
import {
|
||||
buildFlow,
|
||||
@@ -57,7 +64,7 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
|
||||
const overrideConfig: ICommonObject = { ...req.body }
|
||||
for (const file of files) {
|
||||
const fileNames: string[] = []
|
||||
const fileBuffer = fs.readFileSync(file.path)
|
||||
const fileBuffer = await getFileFromUpload(file.path ?? file.key)
|
||||
// Address file name with special characters: https://github.com/expressjs/multer/issues/1104
|
||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
|
||||
const storagePath = await addArrayFilesToStorage(file.mimetype, fileBuffer, file.originalname, fileNames, chatflowid)
|
||||
@@ -90,7 +97,7 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
|
||||
overrideConfig[fileInputField] = storagePath
|
||||
}
|
||||
|
||||
fs.unlinkSync(file.path)
|
||||
await removeSpecificFileFromUpload(file.path ?? file.key)
|
||||
}
|
||||
if (overrideConfig.vars && typeof overrideConfig.vars === 'string') {
|
||||
overrideConfig.vars = JSON.parse(overrideConfig.vars)
|
||||
|
||||
Reference in New Issue
Block a user