user-export.ts 1009 B

12345678910111213141516171819202122232425
  1. import { CONFIG } from '@server/initializers/config.js'
  2. import { MUserExport } from '@server/types/models/index.js'
  3. import { generateUserExportObjectStorageKey } from './keys.js'
  4. import { getObjectStorageFileSize, removeObject, storeStream } from './shared/index.js'
  5. import { Readable } from 'stream'
  6. export function storeUserExportFile (stream: Readable, userExport: MUserExport) {
  7. return storeStream({
  8. stream,
  9. objectStorageKey: generateUserExportObjectStorageKey(userExport.filename),
  10. bucketInfo: CONFIG.OBJECT_STORAGE.USER_EXPORTS,
  11. isPrivate: true
  12. })
  13. }
  14. export function removeUserExportObjectStorage (userExport: MUserExport) {
  15. return removeObject(generateUserExportObjectStorageKey(userExport.filename), CONFIG.OBJECT_STORAGE.USER_EXPORTS)
  16. }
  17. export function getUserExportFileObjectStorageSize (userExport: MUserExport) {
  18. return getObjectStorageFileSize({
  19. key: generateUserExportObjectStorageKey(userExport.filename),
  20. bucketInfo: CONFIG.OBJECT_STORAGE.USER_EXPORTS
  21. })
  22. }