-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
cloudflare-r2-binding
driver (#235)
- Loading branch information
Showing
5 changed files
with
789 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# CloudFlare R2 (binding) | ||
|
||
::alert | ||
This is an experimental driver! This driver only works in a cloudflare worker environment and cannot be used in other runtime environments such as Node.js (r2-http driver is coming soon) | ||
:: | ||
|
||
Store data in [Cloudflare R2](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/) buckets and access from worker bindings. | ||
|
||
You need to create and assign a R2 bucket. See [R2 Bindings](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/#create-a-binding) for more information. | ||
|
||
```js | ||
import { createStorage } from "unstorage"; | ||
import cloudflareR2BindingDriver from "unstorage/drivers/cloudflare-r2-binding"; | ||
|
||
// Using binding name to be picked from globalThis | ||
const storage = createStorage({ | ||
driver: cloudflareR2BindingDriver({ binding: "MY_BUCKET" }), | ||
}); | ||
|
||
// Directly setting binding | ||
const storage = createStorage({ | ||
driver: cloudflareR2BindingDriver({ binding: globalThis.MY_BUCKET }), | ||
}); | ||
``` | ||
|
||
**Options:** | ||
|
||
- `binding`: Bucket binding or name. | ||
- `base`: Prefix all keys with base. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,4 +133,4 @@ | |
} | ||
}, | ||
"packageManager": "pnpm@8.6.5" | ||
} | ||
} |
Oops, something went wrong.