Skip to content

Commit fa0461e

Browse files
authored
R2 docs (#937)
* add empty release notes * add R2 config to the examples
1 parent 2b68ec1 commit fa0461e

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

docs/usage.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ that can access your data. Available ObjectStores are described in the [obstore
5959
from obspec_utils.registry import ObjectStoreRegistry
6060
from obstore.store import from_url
6161

62-
6362
from virtualizarr import open_virtual_dataset, open_virtual_mfdataset
6463
from virtualizarr.parsers import HDFParser
6564

@@ -71,6 +70,35 @@ that can access your data. Available ObjectStores are described in the [obstore
7170

7271
```
7372

73+
=== "R2"
74+
75+
```python
76+
77+
import xarray as xr
78+
from obstore.store import S3Store
79+
from obspec_utils.registry import ObjectStoreRegistry
80+
81+
from virtualizarr import open_virtual_dataset, open_virtual_mfdataset
82+
from virtualizarr.parsers import HDFParser
83+
84+
endpoint = "https://f0b62eebfbdde1133378bfe3958325f6.r2.cloudflarestorage.com"
85+
access_key_id = "<access_key_id>"
86+
secret_access_key = "<secret_access_key>"
87+
path = "<path_to_files>"
88+
scheme = "s3://"
89+
bucket_name = "<bucket_name>"
90+
bucket = f"{scheme}{bucket_name}"
91+
92+
# create anon s3 store
93+
store = S3Store.from_url(f"{bucket}", endpoint=endpoint, skip_signature=True)
94+
95+
# create s3 store with aws-style credentials
96+
store = S3Store.from_url(f"{bucket}", endpoint=endpoint, access_key_id=access_key_id, secret_access_key=secret_access_key)
97+
98+
registry = ObjectStoreRegistry({f"{bucket}": store})
99+
100+
```
101+
74102
=== "HTTP"
75103

76104
```python

0 commit comments

Comments
 (0)