aws / aws-sdk-js-codemod

Codemod scripts to update AWS SDK for JavaScript APIs.
MIT No Attribution
71 stars 10 forks source link

[Bug]: No transformation for getObject(params).createReadStream() #862

Open trivikr opened 5 months ago

trivikr commented 5 months ago

Self-service

Describe the bug

No transformation for getObject(params).createReadStream()

Steps to reproduce

import { S3 } from "aws-sdk";
import { Readable } from "stream";

const client = new S3({ region: "us-west-2" });
const response: Readable = client
  .getObject({ Bucket: "my-bucket", Key: "my-key" })
  .createReadStream();

Observed behavior

import { S3 } from "@aws-sdk/client-s3";
import { Readable } from "stream";

const client = new S3({
  region: "us-west-2"
});
const response: Readable = client
  .getObject({ Bucket: "my-bucket", Key: "my-key" })
  .createReadStream();

This is an issue since createReadStream does not exist on getObject in v3.

Expected behavior

import { S3 } from "aws-sdk";
import { Readable } from "stream";

const client = new S3({ region: "us-west-2" });
const response: Readable = (await client
  .getObject({ Bucket: "my-bucket", Key: "my-key" }))
  .Body;

Environment

aws-sdk-js-codemod: 1.3.6
- jscodeshift: 0.15.2
- recast: 0.23.4

Additional context

trivikr commented 3 months ago

https://github.com/RocketChat/Rocket.Chat/blob/3da6e14f97572c91073f12ed4ebdb1eb19d23016/apps/meteor/app/file-upload/ufs/AmazonS3/server.ts#L151