Can I write a data URI to an R2 bucket?

Is it possible to write to an R2 bucket with a base64 data URI i.e.
await env.r2_pub.put('some/file', 'data:image/png;base64,i5Gkw...');

? That fails (it creates a text file with literally that content), but perhaps there's a way to encode the file contents first such that R2 accepts it?
Was this page helpful?