What sort of stuff would people want in

What sort of stuff would people want in a “using R2 with Workers” guide/reference? I’m thinking: - Uploading files, both from requests to the Worker and subrequests - FormData vs streaming the body - Retrieving files, including handling httpMetadata and ETags - Listing files, dealing with pagination using cursors - Deleting files, using a preshared secret in the request - Handling range & conditionals - Using waitUntil for uploads in the event you want to trade off error handling/retries for a faster response to user https://developers.cloudflare.com/r2/examples/demo-worker/ has the bulk of the “raw” code but I’d like to have individual headings, smaller and more focused code blocks & that opens up the ability to talk a bit more about it in terms of “why” instead of just “how”
24 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Erisa
Erisa2y ago
this has support for range and all of the expected goodies: https://github.com/kotx/render/blob/master/src/index.ts
GitHub
render/index.ts at master · kotx/render
Cloudflare Worker to proxy and cache requests to R2 - render/index.ts at master · kotx/render
Erisa
Erisa2y ago
No description
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Erisa
Erisa2y ago
What do you mean? Would you like to see more theoretical documentation for R2 explaining how all of these functions work and why they work the way they do? Because I do agree that would be nice
kian
kian2y ago
that's what my original message in this thread was about
Erisa
Erisa2y ago
Aha!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
kian
kian2y ago
an actual fully fledged guide with individual headings and explanations rather than raw code
Erisa
Erisa2y ago
Yeah that would be great
kian
kian2y ago
handling conditionals is always not-very-fun but the DX around that should be improving (https://discord.com/channels/595317990191398933/940663374377783388/999766836172312708)
Erisa
Erisa2y ago
I believe render was mostly made by observing what different clients require for specific functionality (like ranges for aria2c multithreaded downloads and media scrubbing) and diving into mdn explanations of how a webserver is supposed to behave and working out how to map that to R2 operations So something documenting all that and explaining in plain english is definitely a good idea
kian
kian2y ago
the docs currently refer you to the HTTP RFC that's how bad describing conditionals is they're 'easy' but if you want to keep semantic and do the right response codes depending on which conditional fail then blegh but miniflare's r2 implementation has all of it now
Erisa
Erisa2y ago
I believe @kotchu was looking through pages like https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests
HTTP conditional requests - HTTP | MDN
HTTP has a concept of conditional requests, where the result, and even the success of a request, can be changed by comparing the affected resources with the value of a validator. Such requests can be useful to validate the content of a cache, and sparing a useless control, to verify the integrity of a document, like when resuming a download, or ...
kian
kian2y ago
so you could probably just c/p it
Erisa
Erisa2y ago
Which are still quite dense to sift through
kian
kian2y ago
that's what the docs opted to do for the s3 extensions (putobject now supports conditionals)
kian
kian2y ago
No description
kian
kian2y ago
probably easier to consume than RFCs RFCs are weird
Erisa
Erisa2y ago
yeah a lot of the mdn articles are just RFCs reformatted for the everyday person to consume
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
kian
kian2y ago
having them split up means you can talk about it without having 20 lines of comments
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View