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

Modify the value of FILE_UPLOAD for MongoDB to 'mongodb' from 'gridfs'

Yuki Takei 7 лет назад
Родитель
Сommit
d91abc671d
5 измененных файлов с 16 добавлено и 5 удалено
  1. 1 1
      CHANGES.md
  2. 5 1
      README.md
  3. 1 1
      config/env.dev.js
  4. 1 1
      src/server/routes/attachment.js
  5. 8 1
      src/server/service/file-uploader/index.js

+ 1 - 1
CHANGES.md

@@ -3,7 +3,7 @@ CHANGES
 
 
 ## 3.2.9-RC
 ## 3.2.9-RC
 
 
-* 
+* Feature: Attachment Storing to MongoDB GridFS
 
 
 ## 3.2.8
 ## 3.2.8
 
 

+ 5 - 1
README.md

@@ -163,7 +163,11 @@ Environment Variables
     * PASSWORD_SEED: A password seed used by password hash generator.
     * PASSWORD_SEED: A password seed used by password hash generator.
     * SECRET_TOKEN: A secret key for verifying the integrity of signed cookies.
     * SECRET_TOKEN: A secret key for verifying the integrity of signed cookies.
     * SESSION_NAME: The name of the session ID cookie to set in the response by Express. default: `connect.sid`
     * SESSION_NAME: The name of the session ID cookie to set in the response by Express. default: `connect.sid`
-    * FILE_UPLOAD: `aws` (default), `local`, `none`
+    * FILE_UPLOAD: Attached files storage. default: `aws`
+      * `aws` : AWS S3 (needs AWS settings on Admin page)
+      * `mongodb` : MongoDB GridFS (Setting-less)
+      * `local` : Server's Local file system (Setting-less)
+      * `none` : Disable file uploading
 * **Option to integrate with external systems**
 * **Option to integrate with external systems**
     * HACKMD_URI: URI to connect to [HackMD(CodiMD)](https://hackmd.io/) server.
     * HACKMD_URI: URI to connect to [HackMD(CodiMD)](https://hackmd.io/) server.
         * **This server must load the GROWI agent. [Here's how to prepare it](https://docs.growi.org/management-cookbook/integrate-with-hackmd).**
         * **This server must load the GROWI agent. [Here's how to prepare it](https://docs.growi.org/management-cookbook/integrate-with-hackmd).**

+ 1 - 1
config/env.dev.js

@@ -1,6 +1,6 @@
 module.exports = {
 module.exports = {
   NODE_ENV: 'development',
   NODE_ENV: 'development',
-  FILE_UPLOAD: 'local',
+  FILE_UPLOAD: 'mongodb',
   // MATHJAX: 1,
   // MATHJAX: 1,
   ELASTICSEARCH_URI: 'http://localhost:9200/growi',
   ELASTICSEARCH_URI: 'http://localhost:9200/growi',
   HACKMD_URI: 'http://localhost:3010',
   HACKMD_URI: 'http://localhost:3010',

+ 1 - 1
src/server/routes/attachment.js

@@ -55,7 +55,7 @@ module.exports = function(crowi, app) {
    * @apiParam {String} pageId, fileName
    * @apiParam {String} pageId, fileName
    */
    */
   api.get = async function(req, res) {
   api.get = async function(req, res) {
-    if (process.env.FILE_UPLOAD != 'gridfs') {
+    if (process.env.FILE_UPLOAD !== 'mongodb') {
       return res.status(400);
       return res.status(400);
     }
     }
     const pageId = req.params.pageId;
     const pageId = req.params.pageId;

+ 8 - 1
src/server/service/file-uploader/index.js

@@ -1,8 +1,15 @@
+const envToModuleMappings = {
+  aws:     'aws',
+  local:   'local',
+  none:    'none',
+  mongodb: 'gridfs',
+};
+
 class FileUploaderFactory {
 class FileUploaderFactory {
 
 
   getUploader(crowi) {
   getUploader(crowi) {
     if (this.uploader == null) {
     if (this.uploader == null) {
-      const method = process.env.FILE_UPLOAD || 'aws';
+      const method = envToModuleMappings[process.env.FILE_UPLOAD] || 'aws';
       const modulePath = `./${method}`;
       const modulePath = `./${method}`;
       this.uploader = require(modulePath)(crowi);
       this.uploader = require(modulePath)(crowi);
     }
     }