Parcourir la source

test add query

yusueketk il y a 7 ans
Parent
commit
40a29dd735
2 fichiers modifiés avec 3 ajouts et 5 suppressions
  1. 2 4
      src/server/routes/attachment.js
  2. 1 1
      src/server/service/file-uploader/gridfs.js

+ 2 - 4
src/server/routes/attachment.js

@@ -67,21 +67,19 @@ module.exports = function(crowi, app) {
    * @apiParam {String} attachment_path
    * @apiParam {String} attachment_path
    */
    */
   api.getMongoFile = async function(req, res) {
   api.getMongoFile = async function(req, res) {
-    const filePath = req.filePath;
+    const filePath = req.query.filePath;
     const file = await AttachmentFile.find({filename: filePath}, function(err, file) {
     const file = await AttachmentFile.find({filename: filePath}, function(err, file) {
       if (err) {
       if (err) {
         throw new Error(err);
         throw new Error(err);
       }
       }
     });
     });
     const id = file[0].id;
     const id = file[0].id;
-
-
     const stream = AttachmentFile.readById(id);
     const stream = AttachmentFile.readById(id);
     stream.on('error', function(error) {
     stream.on('error', function(error) {
       throw new Error('failed to load file id:' + id, error);
       throw new Error('failed to load file id:' + id, error);
     });
     });
     stream.on('data', function(data) {
     stream.on('data', function(data) {
-      return data;
+      return data; // [TODO] data可視化用の処理
     });
     });
     stream.on('close', function() {
     stream.on('close', function() {
       debug('GridFS readstream closed');
       debug('GridFS readstream closed');

+ 1 - 1
src/server/service/file-uploader/gridfs.js

@@ -99,7 +99,7 @@ module.exports = function(crowi) {
 
 
 
 
   lib.generateUrl = function(filePath) {
   lib.generateUrl = function(filePath) {
-    const url = 'http://localhost:3000/_api/attachments.getMongo';
+    const url = `http://localhost:3000/_api/attachments.getMongo?filePath=${filePath}`; // [TODO]パス変更
     return url;
     return url;
   };
   };