(
fileBase64: string,
entity: DocumentStore,
orgId: string,
workspaceId: string,
subscriptionId: string,
usageCacheManager: UsageCacheManager
)
| 536 | } |
| 537 | |
| 538 | const _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 | |
| 569 | const _splitIntoChunks = async ( |
| 570 | appDataSource: DataSource, |
no test coverage detected