Browse Source

Code improvement of findDeliveryFile

https://youtrack.weseek.co.jp/issue/GW-7807
- Change return type of findDeliveryFile method
- Remove GetObjectCommandOutput import
I Komang Mudana 3 years ago
parent
commit
bcd231579a
1 changed files with 1 additions and 6 deletions
  1. 1 6
      packages/app/src/server/service/file-uploader/aws.ts

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

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