mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
Feature/Add new doc store upsert and refresh API (#3556)
add new doc store upsert and refresh API
This commit is contained in:
@@ -39,6 +39,7 @@ export const createFileAttachment = async (req: Request) => {
|
||||
const files = (req.files as Express.Multer.File[]) || []
|
||||
const fileAttachments = []
|
||||
if (files.length) {
|
||||
const isBase64 = req.body.base64
|
||||
for (const file of files) {
|
||||
const fileBuffer = fs.readFileSync(file.path)
|
||||
const fileNames: string[] = []
|
||||
@@ -70,13 +71,21 @@ export const createFileAttachment = async (req: Request) => {
|
||||
[fileInputField]: storagePath
|
||||
}
|
||||
}
|
||||
const documents: IDocument[] = await fileLoaderNodeInstance.init(nodeData, '', options)
|
||||
const pageContents = documents.map((doc) => doc.pageContent).join('\n')
|
||||
|
||||
let content = ''
|
||||
|
||||
if (isBase64) {
|
||||
content = fileBuffer.toString('base64')
|
||||
} else {
|
||||
const documents: IDocument[] = await fileLoaderNodeInstance.init(nodeData, '', options)
|
||||
content = documents.map((doc) => doc.pageContent).join('\n')
|
||||
}
|
||||
|
||||
fileAttachments.push({
|
||||
name: file.originalname,
|
||||
mimeType: file.mimetype,
|
||||
size: file.size,
|
||||
content: pageContents
|
||||
content
|
||||
})
|
||||
} catch (error) {
|
||||
throw new Error(`Failed operation: createFileAttachment - ${getErrorMessage(error)}`)
|
||||
|
||||
Reference in New Issue
Block a user