lib-storage should compute MD5 for parts
See original GitHub issueIs your feature request related to a problem? Please describe.
UploadPart API supports specifying MD5/SHA256 to verify each part is received intact. lib-storage
does not allow me to make use of this feature.
Describe the solution you’d like
Add a flag to the Upload constructor that either enables or disables automatic MD5 computation for each part.
Describe alternatives you’ve considered
Fork lib-storage
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
Does @aws-sdk/lib-storage Upload - Multipart ... - GitHub
Multipart uploads must include the MD5 hash on each individual part. My files are many GB in size, so I want to utilize...
Read more >@aws-sdk/lib-storage | AWS SDK for JavaScript v3
This abstraction enables uploading large files or streams of unknown size due to the use of multipart uploads under the hood. import {...
Read more >Consolidate content md5 of various parts - MSDN - Microsoft
Hi,. We use java storage client library to transfer files to Azure. For a large file, we split the file in to multiple...
Read more >Different Result When Calculating MD5 of Certain Part of a ...
Goals : Make a function to calculate certain part of a file where we skips certain bytes. Only certain parts of file to...
Read more >Object Storage Service:Multipart upload - Alibaba Cloud
After these parts are uploaded, you can call ... OSS includes the MD5 hash of part data in the ETag header and returns...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay I figured out a workaround using the existing packages in this library. It seems like there is a package called
@aws-sdk/middleware-apply-body-checksum
that most of the commands in the client-s3 use to automatically generate a md5 hash and add the content-md5 header. I was able to get this to work via the following:This will inject the existing package into the middleware stack for all S3 client requests and then you can continue to use the Upload class from lib-storage as normal. There could be other types of requests that you don’t want this middle to run for, so you can conditionally do the
middlewareStack.use
above before your request and then usemiddlewareStack.remove('applyMd5BodyChecksumMiddleware')
to remove it.After running the workaround above, multipart uploads work like a charm when setting
ObjectLockMode
andObjectLockRetainUntilDate
in the upload params.side note: it seems the Upload class expects a type of PutObjectCommandInput for the params config, but when you give it a stream it proceeds to never actually call “PutObject” since it needs to do a multi-part upload. When you compare AWS’s api requirements between PutObject and CreateMultiPartUpload there are some minor differences. One difference is the
Content-MD5
which is expected in the PutObject command but isn’t used in the CreateMultiPartUpload command. Looking through the source it seems like some hacks have been made in the lib-storage library to set the Body key toundefined
as a way around it. It’s a little odd to have params be validated against a command input type that it never even calls and it’s probably why it took so long to debug this issue since originally I kept getting back MalformedXML 400 status code errors from aws.I spent several days to figure all of that out and at the end of the day, a MalformedXML error is really a bug with the sdk itself - not user error. I mention this because using v2 of the aws-sdk-js package might save you a bunch of your time and sanity! 😅