-
Notifications
You must be signed in to change notification settings - Fork 62
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
Enable streaming upload in S3 : put_object #658
base: master
Are you sure you want to change the base?
Conversation
There were two problems: 1) Request did not allow an IO 2) Signing did not permit an unsigned payload (https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)
cccbf1e
to
08b9a04
Compare
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.
Apologies for the long silence here. Could you add some tests to ensure this works as intended?
if !haskey(request.headers, "x-amz-content-sha256") | ||
content_hash = bytes2hex(digest(MD_SHA256, request.content)) | ||
request.headers["x-amz-content-sha256"] = content_hash | ||
else | ||
content_hash = "UNSIGNED-PAYLOAD" | ||
end |
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 can write this a bit more concisely like so:
if !haskey(request.headers, "x-amz-content-sha256") | |
content_hash = bytes2hex(digest(MD_SHA256, request.content)) | |
request.headers["x-amz-content-sha256"] = content_hash | |
else | |
content_hash = "UNSIGNED-PAYLOAD" | |
end | |
content_hash = get!(request.headers, "x-amz-content-sha256") do | |
bytes2hex(digest(MD_SHA256, request.content)) | |
end |
request.headers["x-amz-content-sha256"] = "UNSIGNED-PAYLOAD" | ||
else | ||
request.headers["Content-MD5"] = base64encode( | ||
digest(MD_MD5, request.content)) |
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.
This repository uses the Blue style guide, which puts closing parentheses on the following line in cases like this
digest(MD_MD5, request.content)) | |
digest(MD_MD5, request.content) | |
) |
Supposedly automatic formatting suggestions are set up but that appears to not have occurred here.
There were two problems:
(https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)