-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support: Upgrade aws-sdk to v3 #5863
support: Upgrade aws-sdk to v3 #5863
Conversation
https://youtrack.weseek.co.jp/issue/GW-7758 - Install @aws-sdk/client-s3 - Convert file-uploader aws to typescript (on progress) - Install @aws-sdk/s3-request-presigner to get signedUrl
https://youtrack.weseek.co.jp/issue/GW-7758 - Add delete file and upload file - Add forcePathStyle in aws config
https://youtrack.weseek.co.jp/issue/GW-7631 - Remove aws.js - Remove Expires options in getSignedUrl function param - Update getSignedUrl, add expiresIn option
https://youtrack.weseek.co.jp/issue/GW-7631 - Implement deleteFileByFilePath
@@ -207,7 +212,7 @@ module.exports = function(crowi) { | |||
|
|||
let stream; | |||
try { | |||
stream = s3.getObject(params).createReadStream(); | |||
stream = s3.send(new GetObjectCommand(params)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type of S3Client.send is not Readable
.
I think s3.send(new GetObjectCommand(params)).Body
is what we want here. Please check and change if necessary.
See:
export interface GetObjectOutput {
Body?: Readable | ReadableStream | Blob;
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to return stream.Body
I have also improved type system code in this commit. Please check this as well. |
https://youtrack.weseek.co.jp/issue/GW-7807 - Change return type of findDeliveryFile method - Remove GetObjectCommandOutput import
https://youtrack.weseek.co.jp/issue/GW-7807 - Update return type of findDeliveryFilemethod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, most of your code looks good.
To close this PR, please make sure all the apis works correctly.
} | ||
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; | ||
return stream.Body; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should get the Body
attribute at L216 so the variable name matches to its value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! Important !!
Please make sure the findDeliveryFile
method works correctly.
Especially, please test that the app.get('/download/:id([0-9a-z]{24})' , loginRequired, attachment.api.download);
endpoint works correctly. Please write down what and how you checked this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract Body
attribute from GetObjectCommandOutput
as type for stream variable type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
オリジナルのファイル名でダウンロードできないといけないのでは?
routes/attachment.js には
'Content-Disposition': `attachment;filename*=UTF-8''${encodeURIComponent(attachment.originalName)}`
をセットしてる箇所があるので。
https://youtrack.weseek.co.jp/issue/GW-7807 - Extract Body attribute from GetObjectCommandOutput Interface as type
✨✨ That's perfect, there is no visual difference! ✨✨ Check out the report here. |
https://youtrack.weseek.co.jp/issue/GW-7807
Testing Steps
Configure AWS
Upload attachment from wiki page
Upload Attachment from user profile picture setting