Search
Get Started
CD
Cloudflare Developers
β’
3y ago
chientrm.com
How to set known length for R2 put?
The ReadableStream doesn
't have a field for read
/write length
.
Cloudflare Developers
Join
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
83,043
Members
View on Discord
Was this page helpful?
Yes
No
C
chientrm.com
OP
β’
8/28/23, 1:03 PM
I already put in the
headers
C
chientrm.com
OP
β’
8/28/23, 2:08 PM
If I pass the ReadableStream from
it will upload successfully
C
chientrm.com
OP
β’
8/28/23, 2:08 PM
If I
manually
, it
'll throw the error
.
K
kian
β’
8/28/23, 2:54 PM
you should use a FixedLengthStream if your creating your own
K
kian
you should use a FixedLengthStream if your creating your own
C
chientrm.com
OP
β’
8/28/23, 3:16 PM
anyway I can get the length from the original
?
K
kian
β’
8/28/23, 3:19 PM
Not without buffering it
K
kian
β’
8/28/23, 3:19 PM
If it
's from a request
, just use
K
kian
If it's from a request, just use `request.body`
C
chientrm.com
OP
β’
8/28/23, 3:24 PM
I
've read the first N bytes of
for the instruction description
. The latter part of body is data as parameters for the instruction
.
C
chientrm.com
OP
β’
8/28/23, 3:28 PM
How about
, first
with the instruction body and the second
with data
?
C
chientrm.com
anyway I can get the length from the original `ReadableStream`?
M
MrBBot
β’
8/29/23, 8:17 AM
You should be able to get this from the
header on the request
M
MrBBot
You should be able to get this from the `Content-Length` header on the request
C
chientrm.com
OP
β’
8/29/23, 8:19 AM
I can
't
, on the other side I only got
without the headers
.
C
chientrm.com
I've read the first N bytes of `request.body` for the instruction description. T...
M
MrBBot
β’
8/29/23, 8:21 AM
Isn
βt the stream coming from
? Could you read that length
, then subtract N for the data stream
?
M
MrBBot
Isnβt the stream coming from `request.body`? Could you read that length, then su...
C
chientrm.com
OP
β’
8/29/23, 8:23 AM
That sounds like it
content-length
content-length
request.body
request.body
request.body
request.body
request.body
request.body
request.body
request.body
new ReadableStream
new ReadableStream
ReadableStream
ReadableStream
ReadableStream
ReadableStream
fetch
fetch
fetch
fetch
Content-Length
Content-Length