yusueketk 7 лет назад
Родитель
Сommit
132e63bcb8
2 измененных файлов с 5 добавлено и 5 удалено
  1. 4 4
      src/server/routes/attachment.js
  2. 1 1
      src/server/routes/index.js

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

@@ -56,15 +56,15 @@ module.exports = function(crowi, app) {
    * @apiName get
    * @apiGroup Attachment
    *
-   * @apiParam {String} pageId, fileId
+   * @apiParam {String} pageId, fileName
    */
   api.get = async function(req, res) {
     if (process.env.FILE_UPLOAD != 'gridfs') {
-      return res.status(404);
+      return res.status(400);
     }
     const pageId = req.params.pageId;
-    const fileId = req.params.fileId;
-    const filePath = `attachment/${pageId}/${fileId}`;
+    const fileName = req.params.fileName;
+    const filePath = `attachment/${pageId}/${fileName}`;
     const fileData = await fileUploader.getFileData(filePath);
     res.set('Content-Type', fileData.contentType);
     return res.send(ApiResponse.success(fileData.data));

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

@@ -176,7 +176,7 @@ module.exports = function(crowi, app) {
   app.get( '/:id([0-9a-z]{24})'       , loginRequired(crowi, app, false) , page.api.redirector);
   app.get( '/_r/:id([0-9a-z]{24})'    , loginRequired(crowi, app, false) , page.api.redirector); // alias
   app.get( '/download/:id([0-9a-z]{24})' , loginRequired(crowi, app, false) , attachment.api.download);
-  app.get( '/attachment/:pageId/:fileId'  , loginRequired(crowi, app, false), attachment.api.get);
+  app.get( '/attachment/:pageId/:fileName'  , loginRequired(crowi, app, false), attachment.api.get);
 
   app.get( '/_search'                 , loginRequired(crowi, app, false) , search.searchPage);
   app.get( '/_api/search'             , accessTokenParser , loginRequired(crowi, app, false) , search.api.search);