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

use original fileUrl directly (not proxy) -- 2017.05.08 Yuki Takei

reason:
1. this is buggy
2. ensure backward compatibility of data
Yuki Takei 9 лет назад
Родитель
Сommit
dd68eadbc7
2 измененных файлов с 17 добавлено и 4 удалено
  1. 7 1
      lib/models/attachment.js
  2. 10 3
      lib/routes/attachment.js

+ 7 - 1
lib/models/attachment.js

@@ -28,7 +28,13 @@ module.exports = function(crowi) {
   });
   });
 
 
   attachmentSchema.virtual('fileUrl').get(function() {
   attachmentSchema.virtual('fileUrl').get(function() {
-    return `/files/${this._id}`;
+    // NOTE: use original generated Url directly (not proxy) -- 2017.05.08 Yuki Takei
+    // reason:
+    //   1. this is buggy (doesn't work on Win)
+    //   2. ensure backward compatibility of data
+
+    // return `/files/${this._id}`;
+    return fileUploader.generateUrl(this.filePath);
   });
   });
 
 
   attachmentSchema.statics.findById = function(id) {
   attachmentSchema.statics.findById = function(id) {

+ 10 - 3
lib/routes/attachment.js

@@ -64,13 +64,20 @@ module.exports = function(crowi, app) {
 
 
     Attachment.getListByPageId(id)
     Attachment.getListByPageId(id)
     .then(function(attachments) {
     .then(function(attachments) {
-      var config = crowi.getConfig();
-      var baseUrl = (config.crowi['app:url'] || '');
+
+      // NOTE: use original fileUrl directly (not proxy) -- 2017.05.08 Yuki Takei
+      // reason:
+      //   1. this is buggy (doesn't work on Win)
+      //   2. ensure backward compatibility of data
+
+      // var config = crowi.getConfig();
+      // var baseUrl = (config.crowi['app:url'] || '');
       return res.json(ApiResponse.success({
       return res.json(ApiResponse.success({
         attachments: attachments.map(at => {
         attachments: attachments.map(at => {
           var fileUrl = at.fileUrl;
           var fileUrl = at.fileUrl;
           at = at.toObject();
           at = at.toObject();
-          at.url = baseUrl + fileUrl;
+          // at.url = baseUrl + fileUrl;
+          at.url = fileUrl;
           return at;
           return at;
         })
         })
       }));
       }));