Skip to content
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

fix(util-body-length-node): calculateBodyLength for Readable stream with range #2637

Closed
wants to merge 1 commit into from

Conversation

pingiun
Copy link

@pingiun pingiun commented Aug 3, 2021

Description

A ReadStream created with createReadStream(file, {start: 0, end: 0}) would not be detected by this function, or would falsly just use the size of the original file at body.path. This uses the end and start numbers if present, both are inclusive so 1 is added.

Inclusive according to: https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options

Additional context

I encountered this bug while uploading a multipart file to s3


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@30831c7). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2637   +/-   ##
=======================================
  Coverage        ?   60.62%           
=======================================
  Files           ?      515           
  Lines           ?    27691           
  Branches        ?     6805           
=======================================
  Hits            ?    16789           
  Misses          ?    10902           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30831c7...98f684d. Read the comment docs.

@AllanZhengYP AllanZhengYP changed the title Fix calculateBodyLength for ReadStream with range fix(util-body-length-node): calculateBodyLength for Readable stream with range Aug 7, 2021
Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ith range

A ReadStream created with createReadStream(file, {start: 0, end: 0}) would not be detected by this function, or would falsly just use the size of the original file at body.path. This uses the end and start numbers if present, both are inclusive so 1 is added.

Inclusive according to: https://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options
@pingiun
Copy link
Author

pingiun commented Aug 7, 2021

Note that this still doesn't handle filestreams with just an fd and no path, also doesn't handle a start but no end

@pingiun pingiun requested a review from AllanZhengYP August 7, 2021 10:34
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 98f684d
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@kuhe
Copy link
Contributor

kuhe commented Aug 9, 2023

this package has moved, opened new PR at the new site

@kuhe kuhe closed this Aug 9, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants