hey guys! is there a good example

hey guys! is there a good example repository where i can find an example of an R2 object being used to set as source for a media element? I'm wondering about the wire up, I'm close but not exactly there would be awesome, thanks
2 Replies
niconiahi
niconiahiOP9mo ago
this is my current approach but it's not working https://github.com/niconiahi/olga/blob/main/app/routes/_root.sounds.tsx
GitHub
olga/app/routes/_root.sounds.tsx at main · niconiahi/olga
Contribute to niconiahi/olga development by creating an account on GitHub.
thipperz
thipperz9mo ago
I believe the issue is when you do return new Response(sound.body) since "sound" is the R2ObjectBody you got with const sound = await env.SOUNDS.get("dudoso.mp3") I believe you could do instead sound.blob() or sound.arrayBuffer() depending on your needs For example I believe you could do: const url = URL.createObjectURL(await sound.blob())
Cloudflare Docs
Workers API reference · Cloudflare R2 docs
The in-Worker R2 API is accessed by binding an R2 bucket to a Worker. The Worker you write can expose external access to buckets via a route or …
Want results from more Discord servers?
Add your server