Просмотр исходного кода

fix getFilePathOnStorage for page bulk export

Futa Arai 1 год назад
Родитель
Сommit
927a29a813
1 измененных файлов с 13 добавлено и 4 удалено
  1. 13 4
      apps/app/src/server/service/file-uploader/gcs.ts

+ 13 - 4
apps/app/src/server/service/file-uploader/gcs.ts

@@ -2,7 +2,9 @@ import { Storage } from '@google-cloud/storage';
 import urljoin from 'url-join';
 
 import type Crowi from '~/server/crowi';
-import { FilePathOnStoragePrefix, ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
+import {
+  AttachmentType, FilePathOnStoragePrefix, ResponseMode, type RespondOptions,
+} from '~/server/interfaces/attachment';
 import type { IAttachmentDocument } from '~/server/models';
 import loggerFactory from '~/utils/logger';
 
@@ -35,9 +37,16 @@ function getGcsInstance() {
 function getFilePathOnStorage(attachment: IAttachmentDocument) {
   const namespace = configManager.getConfig('crowi', 'gcs:uploadNamespace');
   // const namespace = null;
-  const dirName = (attachment.page != null)
-    ? FilePathOnStoragePrefix.attachment
-    : FilePathOnStoragePrefix.user;
+  let dirName: string;
+  if (attachment.attachmentType === AttachmentType.PAGE_BULK_EXPORT) {
+    dirName = FilePathOnStoragePrefix.pageBulkExport;
+  }
+  else if (attachment.page != null) {
+    dirName = FilePathOnStoragePrefix.attachment;
+  }
+  else {
+    dirName = FilePathOnStoragePrefix.user;
+  }
   const filePath = urljoin(namespace || '', dirName, attachment.fileName);
 
   return filePath;