yusuketk 5 лет назад
Родитель
Сommit
983215c273

+ 4 - 2
src/client/js/components/Page/PageShareManagement.jsx

@@ -30,8 +30,8 @@ const PageShareManagement = (props) => {
   async function exportPageHundler(type) {
     const { pageId, revisionId } = pageContainer.state;
     try {
+      // TODO GW-3062 現状では pdf ファイル系k色の場合空のデータがダウンロードされるので要修正
       const responseType = type === 'pdf' ? 'arraybuffer' : 'json';
-      // const responseType = 'stream';
       const data = await appContainer.apiv3Get('/page/export',
         {
           pageId,
@@ -39,14 +39,16 @@ const PageShareManagement = (props) => {
           type,
           responseType,
         });
+      const blobType = type === 'pdf' ? 'application/pdf' : 'application/json';
       const blob = new Blob(
         [data],
-        { type: 'text/plain' },
+        { type: blobType },
       );
       const link = document.createElement('a');
       link.href = window.URL.createObjectURL(blob);
       link.download = `${pageId}.${type}`;
       link.click();
+      link.remove();
     }
     catch (err) {
       toastError(Error(t('export_bulk.failed_to_export')));

+ 2 - 1
src/server/service/export.js

@@ -363,8 +363,9 @@ class ExportService {
         await fs.writeFileSync(filePath, markdown);
       }
       else if (type === 'pdf') {
-        filePath = path.join(baseDir, `${tmpFileName}.md`);
+        filePath = path.join(baseDir, `${tmpFileName}.pdf`);
         await this.convertToPdfAndWriteFile(markdown, filePath);
+        res.contentType('application/pdf');
       }
       else {
         throw new Error('requested file format is invaild');