Open juretopolak opened 10 months ago
Hi dear @juretopolak. Feel free to draft a PR if you are willing to help supporting this driver earlier 👍🏼
Hi @pi0. I'm actually a TypeScript newbie, so I doubt my PR would be useful at all. 🙂 Maybe someday in the future... until then I'll keep learning and admiring the work you experts do. 👌
Hi @juretopolak I had to deal with this recently, I found that the best way is to use aws4fetch
which works on all environments, including workers.
You need something like this, inside for example /api/upload-file.js
:
import { AwsClient } from 'aws4fetch'
const aws = new AwsClient({ accessKeyId, secretAccessKey })
// Then you can just send a PUT / GET / DELETE request
await aws.fetch(R2_BUCKET_URL, { body: buffer, method: 'PUT', ContentType: type })
It's super easy with aws4fetch
- With native $fetch is more complex because you need to somehow generate the AWS Signature Version 4
Really nice find. I certainly like to consider aws4fetch. There are small items (such as crypto polyfill to use uncrypto) we can either (temporarily) inline impl to make those or work with @mhart if you would like to make it happen!
Describe the feature
I would just like to ask if you have any approx. date when r2-http driver will be released? I would like to use CF R2 in the Node environment and I'm wondering if it is better to wait for a "native" nuxt/nitro/unstorage driver or the release is not close so it's better to go with another solution? 🙂
Thanks!
Additional information