You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Body Data is unsupported format, expected data to be one of: string | Uint8Array | Buffer | Readable | ReadableStream | Blob
Expected Behavior
The example code should work without throwing errors.
Possible Solution
After much searching and piecing together of various answers I found that the following two methods can be used to turn a node ReadStream into a ReadableStream. (In an electron app using node filesystem apis. I don't know if this would work in vanilla node.)
/** * Taken from Next.js doc * https://nextjs.org/docs/app/building-your-application/routing/router-handlers#streaming * Itself taken from mozilla doc * https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#convert_async_iterator_to_stream * @param {*} iterator * @returns {ReadableStream} */iteratorToStream(iterator){returnnewReadableStream({asyncpull(controller){const{ value, done }=awaititerator.next()if(done){controller.close()}else{controller.enqueue(newUint8Array(value))}},})}/** * From https://github.com/MattMorgis/async-stream-generator */async*nodeStreamToIterator(stream){forawait(constchunkofstream){yieldchunk;}}
Hi @jagthedrummer - thanks for reaching out, sharing feedback on our documentations and workarounds.
As we're always working on improving our docs to be more clear, concise and effective, feedback like this are crucial to our work.
As you'd probably already know, the reason behind the error is the Body Data type mismatch which was sent and rejected by S3. I haven't attempted to reproduce it with electron app but as soon as we can confirm, will update the code example accordingly.
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
Also, the bot seems counterproductive and frankly kind of hostile to the idea that people should let you know about things that aren't working as expected. The message it seems to send is "we didn't bother to get around to this, so we're going to throw it in the trash".
github-actionsbot
removed
closing-soon
This issue will automatically close in 4 days unless further comments are made.
response-requested
Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
labels
Jun 1, 2024
Checkboxes for prior research
Describe the bug
This example code doesn't work:
https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-storage/example-code/file-upload.ts
When I run that an error is thrown saying:
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v18.15.0
Reproduction Steps
Run this example code:
aws-sdk-js-v3/lib/lib-storage/example-code/file-upload.ts
Lines 1 to 24 in 9f65b40
Observed Behavior
And error is thrown that says:
Expected Behavior
The example code should work without throwing errors.
Possible Solution
After much searching and piecing together of various answers I found that the following two methods can be used to turn a node
ReadStream
into aReadableStream
. (In an electron app using node filesystem apis. I don't know if this would work in vanilla node.)So then instead of this:
aws-sdk-js-v3/lib/lib-storage/example-code/file-upload.ts
Line 6 in 9f65b40
You can do this:
Additional Information/Context
I'm using this in an electron app.
A few related issues, none of which seem to contain a full working resolution:
#2365
#2183
#2145
The text was updated successfully, but these errors were encountered: