How to set known length for R2 put?

The ReadableStream doesn't have a field for read/write length.
No description
9 Replies
chientrm
chientrmOP15mo ago
I already put in the content-length headers 🤔 If I pass the ReadableStream from request.body it will upload successfully If I new ReadableStream manually, it'll throw the error.
kian
kian15mo ago
you should use a FixedLengthStream if your creating your own
chientrm
chientrmOP15mo ago
anyway I can get the length from the original ReadableStream?
kian
kian15mo ago
Not without buffering it If it's from a request, just use request.body
chientrm
chientrmOP15mo ago
I've read the first N bytes of request.body for the instruction description. The latter part of body is data as parameters for the instruction. How about, first fetch with the instruction body and the second fetch with data?
MrBBot
MrBBot15mo ago
You should be able to get this from the Content-Length header on the request
chientrm
chientrmOP15mo ago
I can't, on the other side I only got ReadableStream without the headers.
MrBBot
MrBBot15mo ago
Isn’t the stream coming from request.body? Could you read that length, then subtract N for the data stream?
chientrm
chientrmOP15mo ago
That sounds like it 👍
Want results from more Discord servers?
Add your server