浏览代码

修改文件存储路径

asd123a20 3 年之前
父节点
当前提交
3593f670c0
共有 3 个文件被更改,包括 16 次插入15 次删除
  1. 二进制
      app/public/resource/1750ee90-e43d-11eb-abea-7db7203356f5.jpeg
  2. 2 2
      app/service/files.js
  3. 14 13
      config/config.default.js

二进制
app/public/resource/1750ee90-e43d-11eb-abea-7db7203356f5.jpeg


+ 2 - 2
app/service/files.js

@@ -74,8 +74,8 @@ class FilesService extends Service {
       const index = filename.indexOf('.');
       const fileType = filename.slice(index, filename.length);
       const uuid = uuidv1();
-      const filepath = `/public/${type === 'files' ? 'files' : 'resource'}/${uuid}${fileType}`;
-      const paths = path.join(this.app.baseDir, `/app${filepath}`);
+      const filepath = `${this.app.config.filespath}${type === 'files' ? 'files' : 'resource'}/${uuid}${fileType}`;
+      const paths = path.join(filepath);
       // 存储
       const result = await new Promise((resolve, reject) => {
         const remoteFileStream = fs.createWriteStream(paths);

+ 14 - 13
config/config.default.js

@@ -47,22 +47,23 @@ module.exports = appInfo => {
     secret: '123456',
   };
   config.userSecret = '123456';
+  config.filespath = '/home/cms/filespath/';
   // 数据库配置
-  // config.mongoose = {
-  //   url: 'mongodb://172.17.116.7:27018/example',
-  //   options: {
-  //     user: 'root',
-  //     pass: 'cms@cc-lotus',
-  //     authSource: 'admin',
-  //     useNewUrlParser: true,
-  //     useCreateIndex: true,
-  //     useUnifiedTopology: true,
-  //   },
-  // };
   config.mongoose = {
-    url: 'mongodb://127.0.0.1:27017/example',
-    options: {},
+    url: 'mongodb://172.17.116.7:27018/cms',
+    options: {
+      user: 'root',
+      pass: 'cms@cc-lotus',
+      authSource: 'admin',
+      useNewUrlParser: true,
+      useCreateIndex: true,
+      useUnifiedTopology: true,
+    },
   };
+  // config.mongoose = {
+  //   url: 'mongodb://127.0.0.1:27017/example',
+  //   options: {},
+  // };
   // 异常捕获
   config.middleware = [ 'errorHandler' ];
   config.errorHandler = {