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(hash-stream-node): disable createReadStream with file descriptor #3369

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Feb 25, 2022

Issue

Fixes: #3368

Description

Disables createReadStream with file descriptor

Testing

PutObject
import { S3 } from "../aws-sdk-js-v3/clients/client-s3/dist-cjs/index.js";
import { createReadStream } from "fs";

const region = "us-west-2";
const client = new S3({ region });

// File created with command "(for i in {1..10000}; do echo $i "hello world"; done) > hello-world.txt"
const fileName = "hello-world.txt";
const readableStream = createReadStream(fileName);

const Bucket = "aws-sdk-js-trivikr-flexible-checksums-testing";
const Key = fileName;
const Body = readableStream;
const ChecksumAlgorithm = "CRC32";

await client.putObject({ Bucket, Key, Body, ChecksumAlgorithm });
GetObject
import { S3 } from "../aws-sdk-js-v3/clients/client-s3/dist-cjs/index.js";
import { createWriteStream } from "fs";

const region = "us-west-2";
const client = new S3({ region });

const fileName = "hello-world.txt";
const Bucket = "aws-sdk-js-trivikr-flexible-checksums-testing";
const Key = fileName;
const ChecksumMode = "ENABLED";

const { Body } = await client.getObject({ Bucket, Key, ChecksumMode });
const writeStream = createWriteStream("./hello-world-copy.txt");
Body.pipe(writeStream);
diff is empty
$ diff hello-world.txt hello-world-copy.txt

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

@trivikr trivikr requested a review from a team as a code owner February 25, 2022 20:59
@trivikr trivikr merged commit e5e89d2 into aws:main Feb 25, 2022
@trivikr trivikr deleted the fix-fs-create-read-stream branch February 25, 2022 21:23
@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 Mar 12, 2022
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.

[client-s3] client is not sending chunks read from fs.ReadSteam when ChecksumAlgorithm is set
2 participants