Jelajahi Sumber

Code improvement

https://youtrack.weseek.co.jp/issue/GW-7807
- Update return type of findDeliveryFilemethod
I Komang Mudana 3 tahun lalu
induk
melakukan
8725e4b2c4
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      packages/app/src/server/service/file-uploader/aws.ts

+ 6 - 1
packages/app/src/server/service/file-uploader/aws.ts

@@ -5,6 +5,7 @@ import {
   DeleteObjectsCommand,
   PutObjectCommand,
   DeleteObjectCommand,
+  GetObjectCommandOutput,
 } from '@aws-sdk/client-s3';
 import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
 import urljoin from 'url-join';
@@ -210,13 +211,17 @@ module.exports = (crowi) => {
       throw new Error(`Any object that relate to the Attachment (${filePath}) does not exist in AWS S3`);
     }
 
+    let stream: GetObjectCommandOutput;
     try {
-      return (await s3.send(new GetObjectCommand(params))).Body;
+      stream = await s3.send(new GetObjectCommand(params));
     }
     catch (err) {
       logger.error(err);
       throw new Error(`Coudn't get file from AWS for the Attachment (${attachment._id.toString()})`);
     }
+
+    // return stream.Readable
+    return stream.Body;
   };
 
   lib.checkLimit = async(uploadFileSize) => {