mizozobu пре 6 година
родитељ
комит
2a902dcdae

+ 1 - 1
src/client/js/components/Admin/Export/ExportTableMenu.jsx

@@ -34,7 +34,7 @@ class ExportTableMenu extends React.Component {
         <ul className="dropdown-menu" role="menu">
           <li className="dropdown-header">Export Menu</li>
           <li>
-            <a href="/_api/v3/export">
+            <a href={`/_api/v3/export/${this.props.fileName}`}>
               <i className="icon-cloud-download" /> Download
             </a>
           </li>

+ 11 - 2
src/server/routes/apiv3/export.js

@@ -47,16 +47,25 @@ module.exports = (crowi) => {
    *      description: download a zipped json for multiple collections
    *      produces:
    *        - application/json
+   *      parameters:
+   *        - name: fileName
+   *          in: path
+   *          description: file name of zip file
+   *          schema:
+   *            type: string
    *      responses:
    *        200:
    *          description: a zip file
    *          content:
    *            application/zip:
    */
-  router.get('/', async(req, res) => {
+  router.get('/:fileName', async(req, res) => {
     // TODO: add express validator
+    const { fileName } = req.params;
+
     try {
-      return res.download(exportService.getZipFile());
+      const zipFile = exportService.getFile(fileName);
+      return res.download(zipFile);
     }
     catch (err) {
       // TODO: use ApiV3Error

+ 0 - 15
src/server/service/export.js

@@ -238,21 +238,6 @@ class ExportService {
     return jsonFile;
   }
 
-  /**
-   * get the absolute path to the zip file
-   *
-   * @memberOf ExportService
-   * @return {string} absolute path to the zip file
-   */
-  getZipFile() {
-    const zipFile = path.join(this.baseDir, this.zipFileName);
-
-    // throws err if the file does not exist
-    fs.accessSync(zipFile);
-
-    return zipFile;
-  }
-
   /**
    * get a model from collection name
    *