aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

Error: Can't find variable: ReadableStream,use lib-storage upload file to s3 in react-native.

Open zhu-xiaowei opened this issue 2 years ago • 0 comments

Hi @jereztech, I was getting a different error from #2183 use your code. My environment: "react-native": "0.69.5", "@aws-sdk/client-cognito-identity": "^3.168.0", "@aws-sdk/client-s3": "^3.168.0", "@aws-sdk/credential-provider-cognito-identity": "^3.168.0", "@aws-sdk/lib-storage": "^3.168.0"

Code:

const response = await fetch(uri);
const blob = await response.blob();
const upload = new Upload({
      client: s3Client,
      params: {
        Bucket: bucket,
        Key: key,
        Body: blob,
      },
    });
 upload.on("httpUploadProgress", (progress) => {
      console.log("progress:" + progress);
    });

And I still got the error:

Error: Can't find variable: ReadableStream

But when i not to use lib-storage, like:

    s3Client.send(new PutObjectCommand({
      Bucket: bucket,
      Key: key,
      Body: blob,
    })

it's works fine, but i can't get upload progress information with this method.

zhu-xiaowei avatar Sep 12 '22 12:09 zhu-xiaowei