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

Merge pull request #1234 from weseek/feat/307-add-namespace-gcs

refs GW~307: namespace を設定できる
Yuki Takei 6 лет назад
Родитель
Сommit
6bde0ae1cf
2 измененных файлов с 9 добавлено и 1 удалено
  1. 6 0
      src/server/service/config-loader.js
  2. 3 1
      src/server/service/file-uploader/gcs.js

+ 6 - 0
src/server/service/config-loader.js

@@ -232,6 +232,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    TYPES.STRING,
     default: null,
   },
+  GCS_UPLOAD_NAMESPACE: {
+    ns:      'crowi',
+    key:     'gcs:uploadNamespace',
+    type:    TYPES.STRING,
+    default: null,
+  },
 };
 
 class ConfigLoader {

+ 3 - 1
src/server/service/file-uploader/gcs.js

@@ -28,10 +28,12 @@ module.exports = function(crowi) {
   }
 
   function getFilePathOnStorage(attachment) {
+    const namespace = configManager.getConfig('crowi', 'gcs:uploadNamespace');
+    // const namespace = null;
     const dirName = (attachment.page != null)
       ? 'attachment'
       : 'user';
-    const filePath = urljoin(dirName, attachment.fileName);
+    const filePath = urljoin(namespace || '', dirName, attachment.fileName);
 
     return filePath;
   }