workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

Add R2 support

Open zebp opened this issue 3 years ago • 1 comments

zebp avatar Aug 16 '22 19:08 zebp

This is mostly finished, the only problem with it currently is R2 puts only allow a stream of a known length. Currently this is done by using a FixedLengthStream or a request/response body. This is probably blocked until FixedLengthStream is implemented.

zebp avatar Aug 25 '22 15:08 zebp

It looks like FixedLengthStream is also implemented. What is missing to get this merged?

schoenenberg avatar Nov 27 '22 11:11 schoenenberg

It looks like FixedLengthStream is also implemented. What is missing to get this merged?

Just testing against workerd, I've been preoccupied with other things and US holidays so I haven't gotten a chance yet. I hope to have this merged and released this upcoming week.

zebp avatar Nov 27 '22 20:11 zebp

Would love this 🎉

What is the hold up on this? Is there anything I can do to move this forward?

DerZade avatar Dec 25 '22 12:12 DerZade

Would love to see this happen!

Could it make sense to allow a separate .into_body() on Object? This would allow better ergonomics with Option::and_then and it's the intended way of using the type in JS anyways, right?

Example:

let result = bucket.get(key).execute().await?;

match result {
    None => Ok(None),
    Some(body) => match body.body() {
        None => Ok(None),
        Some(body) => Ok(Some(serde_json::from_slice(&body.bytes().await?)?)),
    },
}

I think this is fine, but a chain of and_then would be much nicer, and the only thing blocking that is the body.bytes() function, as it returns a reference to body, even though this doesn't really make sense. Just consuming body makes sense here (and in most cases).

HurricanKai avatar Dec 25 '22 23:12 HurricanKai

It would be really great to see this go in! 🙂 Anything one could do to help?

jakubadamw avatar Jan 04 '23 22:01 jakubadamw

Sadly not, I've been super swamped with other things so I haven't been able to circle back on this yet. I rebased it earlier this week, should just need testing against the production workerd runtime.

zebp avatar Jan 05 '23 15:01 zebp

Sadly not, I've been super swamped with other things so I haven't been able to circle back on this yet. I rebased it earlier this week, should just need testing against the production workerd runtime.

The failing checks should be fixed with another rebase to main. 🙃

DerZade avatar Jan 05 '23 16:01 DerZade

@zebp I noticed this PR does not include support for multipart uploads (which would be great to have for the sake of 1:1 feature equivalence), so I went ahead and implemented that in this branch. I will open a PR once this goes in. 🙂

jakubadamw avatar Jan 07 '23 18:01 jakubadamw

When is it going to be released? I really need it right now 😅

geekyayush avatar Jan 13 '23 08:01 geekyayush

When is it going to be released? I really need it right now 😅

Would love if this would be released as well 😍

@geekyayush If you want to start developing against the new API, you can use it today as follows:

[dependencies]
worker = { git = "https://github.com/cloudflare/workers-rs", branch = "main" }

— see here in the documentation

Not really something you want to do for production, but it works for trying it out 🙃

DerZade avatar Jan 13 '23 08:01 DerZade