outline icon indicating copy to clipboard operation
outline copied to clipboard

Migrate from s3 sdk v2 to v3

Open lng2020 opened this issue 1 year ago • 9 comments

close #5683. Nothing breaking, test with my local setup and everything works. Noticeable change: The s3 SDK v3 method PutObjectCommand doesn't support stream input and it requires a content-length field to be set, which is discussed in https://github.com/aws/aws-sdk-js-v3/issues/2348. So I didn't use PutObjectCommand because I think loading whole files into the buffer may cause a burden. As the issue comment above suggests, I use the Upload class from @aws-sdk/lib-storage which is compatible with v2.

Just in case anyone needs a clear answer: putObject can't write a stream to S3, you have to use the Upload class in @aws-sdk/lib-storage

lng2020 avatar Mar 28 '24 17:03 lng2020

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 28 '24 17:03 CLAassistant

Need to polish about signature-v4-crt

lng2020 avatar Mar 28 '24 18:03 lng2020

Appreciate the help here 🙏

tommoor avatar Mar 28 '24 18:03 tommoor

ready for review

lng2020 avatar Mar 29 '24 04:03 lng2020

So, there is a bug here – when downloading a document that includes an embedded image (Document -> ... -> Download -> Markdown), the image in the generated zip file is 0 bytes.

This would suggest that getFileStream is not working correctly. I checked out main to test it continues to work correctly there.

tommoor avatar Apr 03 '24 03:04 tommoor

So, there is a bug here – when downloading a document that includes an embedded image (Document -> ... -> Download -> Markdown), the image in the generated zip file is 0 bytes.

From my local test, it's been fixed by d520b03 (#6731). There is a long discussion about this getObjectComand https://github.com/aws/aws-sdk-js-v3/issues/1877 about this inflexibility command :smile: and It seems required to use the Readable type. Let me know if there are other malfunctions or other improvements.

lng2020 avatar Apr 03 '24 18:04 lng2020

I really don't want to change the signature of the storage interface here, it's weird to have a method called getFileStream that returns a promise :/ It feels like it was very close before the last round of changes with the exception of that one issue

tommoor avatar Apr 04 '24 00:04 tommoor

can we restore this to async/await style?

I assume this means using async/await in getFileStream and results in a promise returned so I change the signature. Could u kindly specify what the right approach is?

lng2020 avatar Apr 04 '24 00:04 lng2020

I think you're right, this is a terrible limitation of the new version – how annoying.

tommoor avatar Apr 04 '24 00:04 tommoor