How to set known length for R2 put?
The ReadableStream doesn't have a field for read/write length.
9 Replies
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.you should use a FixedLengthStream if your creating your own
anyway I can get the length from the original
ReadableStream
?Not without buffering it
If it's from a request, just use
request.body
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?You should be able to get this from the
Content-Length
header on the requestI can't, on the other side I only got
ReadableStream
without the headers.Isn’t the stream coming from
request.body
? Could you read that length, then subtract N for the data stream?That sounds like it 👍