-
Notifications
You must be signed in to change notification settings - Fork 634
Closed
Labels
bugThis issue is a bug.This issue is a bug.closed-for-stalenessp2This is a standard priority issueThis is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
I'm getting an error that says, "[Error: TypeError: stream.arrayBuffer is not a function (it is undefined)] " although the files are uploaded to the bucket
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/client-s3@^3.712.0, .^3.701.0
Which JavaScript Runtime is this issue in?
React Native
Details of the browser/Node.js/ReactNative version
0.76.2
Reproduction Steps
export const uploadFileToR2 = async (file: any) => {
try {
// move these to cloud or backend or cloud functions
const s3Client = new S3Client({
region: 'auto',
endpoint: `https://${config.CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: config.CLOUDFLARE_ACCESS_KEY,
secretAccessKey: config.CLOUDFLARE_SECRET_KEY
}
})
const { uri, mimeType } = file
// get file from uri
const uriResponse = await fetch(uri)
const contentBody = await uriResponse.blob()
// get file extension
const extension = mime.getExtension(mimeType)
// create random file name
const fileName = `${Date.now()}-${Math.random()
.toString()
.replace('.', '-')}.${extension}`
const putObjectCommand = new PutObjectCommand({
Bucket: config.CLOUDFLARE_BUCKET_NAME,
Key: fileName,
Body: contentBody,
ContentType: mimeType
})
const response = await s3Client.send(putObjectCommand)
return response
} catch (error: any) {
console.log(error?.$response)
throw new Error(error)
}
}
Observed Behavior
(NOBRIDGE) LOG [Error: TypeError: stream.arrayBuffer is not a function (it is undefined)
Expected Behavior
The expected behavior shouldn't throw an error on the catch since the files were uploaded the to bucket successfully
Possible Solution
No response
Additional Information/Context
The tricky part is, the files are uploaded to the bucket. I'm using Cloudflare R2. I even tried older version of the package, still, the error persists. I even tried using axios for getting the blob, still, the error persists.
mlabieniec and swetankkk
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.closed-for-stalenessp2This is a standard priority issueThis is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.