-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cloudflare r2 support (#12)
* init * add impl * supported r2 * updated r2 readme * rm username * fix spelling errors
- Loading branch information
CreaPlus
authored
Nov 9, 2023
1 parent
c6e1b1c
commit 78e0982
Showing
6 changed files
with
356 additions
and
9 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
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
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
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,38 @@ | ||
# Cloudflare R2 | ||
|
||
[Cloudflare R2](https://developers.cloudflare.com/r2/) | ||
|
||
## Usage | ||
|
||
```go | ||
import "https://github.com/casdoor/oss" | ||
|
||
func main() { | ||
storage := r2.New(&r2.Config{{ | ||
AccountId: "Cloudflare AccountId", | ||
AccessKeyId: "Cloudflare R2 AccessKeyId", | ||
AccessKeySecret: "Cloudflare R2 AccessKeySecret", | ||
Bucket: "Cloudflare R2 Bucket", | ||
Endpoint: "https://{AccountId}.r2.cloudflarestorage.com", | ||
|
||
// Save a reader interface into storage | ||
storage.Put("/sample.txt", reader) | ||
|
||
// Get file with path | ||
storage.Get("/sample.txt") | ||
|
||
// Get object as io.ReadCloser | ||
storage.GetStream("/sample.txt") | ||
|
||
// Delete file with path | ||
storage.Delete("/sample.txt") | ||
|
||
// List all objects under path | ||
storage.List("/") | ||
|
||
// Get Public Accessible URL (useful if current file saved privately) | ||
storage.GetURL("/sample.txt") | ||
} | ||
``` | ||
Oops, something went wrong.