MCPcopy
hub / github.com/FlowiseAI/Flowise / _saveFileToStorage

Function _saveFileToStorage

packages/server/src/services/documentstore/index.ts:538–567  ·  view source on GitHub ↗
(
    fileBase64: string,
    entity: DocumentStore,
    orgId: string,
    workspaceId: string,
    subscriptionId: string,
    usageCacheManager: UsageCacheManager
)

Source from the content-addressed store, hash-verified

536}
537
538const _saveFileToStorage = async (
539 fileBase64: string,
540 entity: DocumentStore,
541 orgId: string,
542 workspaceId: string,
543 subscriptionId: string,
544 usageCacheManager: UsageCacheManager
545) => {
546 await checkStorage(orgId, subscriptionId, usageCacheManager)
547
548 const splitDataURI = fileBase64.split(',')
549 const filename = splitDataURI.pop()?.split(':')[1] ?? ''
550 const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
551 const mimePrefix = splitDataURI.pop()
552 let mime = ''
553 if (mimePrefix) {
554 mime = mimePrefix.split(';')[0].split(':')[1]
555 }
556 const { totalSize } = await addSingleFileToStorage(mime, bf, filename, orgId, DOCUMENT_STORE_BASE_FOLDER, entity.id)
557 await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
558
559 return {
560 id: uuidv4(),
561 name: filename,
562 mimePrefix: mime,
563 size: bf.length,
564 status: DocumentStoreStatus.NEW,
565 uploaded: new Date()
566 }
567}
568
569const _splitIntoChunks = async (
570 appDataSource: DataSource,

Callers 1

_saveChunksToStorageFunction · 0.85

Calls 3

checkStorageFunction · 0.90
updateStorageUsageFunction · 0.90
addSingleFileToStorageFunction · 0.85

Tested by

no test coverage detected