You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,15 @@ Simple, fast integration with object storage services like Amazon S3, Google Clo
12
12
13
13
- Sync and async API.
14
14
- Streaming downloads with configurable chunking.
15
+
- Streaming uploads from async or sync iterators.
15
16
- Streaming `list`, with no need to paginate.
16
17
- File-like object API and [fsspec](https://github.com/fsspec/filesystem_spec) integration.
17
18
- Support for conditional put ("put if not exists"), as well as custom tags and attributes.
18
19
- Automatically uses [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html) under the hood for large file objects.
19
20
- Optionally return list results as [Arrow](https://arrow.apache.org/), which is faster than materializing Python `dict`/`list` objects.
20
21
- Easy to install with no required Python dependencies.
21
22
- The [underlying Rust library](https://docs.rs/object_store) is production quality and used in large scale production systems, such as the Rust package registry [crates.io](https://crates.io/).
22
-
-Support for zero-copy data exchange from Rust into Python in `get_range`and `get_ranges`.
23
+
-Zero-copy data exchange between Rust and Python in `get_range`, `get_ranges`, and `put` via the Python buffer protocol.
23
24
- Simple API with static type checking.
24
25
- Helpers for constructing from environment variables and `boto3.Session` objects
25
26
@@ -56,6 +57,10 @@ Classes to construct a store are exported from the `obstore.store` submodule:
56
57
-[`LocalStore`](https://developmentseed.org/obstore/latest/api/store/local/): Local filesystem storage providing the same object store interface.
57
58
-[`MemoryStore`](https://developmentseed.org/obstore/latest/api/store/memory/): A fully in-memory implementation of ObjectStore.
58
59
60
+
Additionally, some middlewares exist:
61
+
62
+
-[`PrefixStore`](https://developmentseed.org/obstore/latest/api/store/middleware/#obstore.store.PrefixStore): Store wrapper that applies a constant prefix to all paths handled by the store.
63
+
59
64
#### Example
60
65
61
66
```py
@@ -81,7 +86,7 @@ All methods for interacting with a store are exported as **top-level functions**
81
86
-[`get`](https://developmentseed.org/obstore/latest/api/get/): Return the bytes that are stored at the specified location.
82
87
-[`head`](https://developmentseed.org/obstore/latest/api/head/): Return the metadata for the specified location
83
88
-[`list`](https://developmentseed.org/obstore/latest/api/list/): List all the objects with the given prefix.
84
-
-[`put`](https://developmentseed.org/obstore/latest/api/put/): Save the provided bytes to the specified location
89
+
-[`put`](https://developmentseed.org/obstore/latest/api/put/): Save the provided buffer to the specified location.
85
90
-[`rename`](https://developmentseed.org/obstore/latest/api/rename/): Move an object from one path to another in the same object store.
86
91
87
92
There are a few additional APIs useful for specific use cases:
- An iterator or iterable of objects implementing the Python buffer
98
+
protocol.
76
99
77
100
Keyword args:
78
101
mode: Configure the `PutMode` for this operation. If this provided and is not `"overwrite"`, a non-multipart upload will be performed. Defaults to `"overwrite"`.
@@ -86,7 +109,14 @@ def put(
86
109
asyncdefput_async(
87
110
store: ObjectStore,
88
111
path: str,
89
-
file: IO[bytes] |Path|bytes,
112
+
file: IO[bytes]
113
+
|Path
114
+
|bytes
115
+
|Buffer
116
+
|AsyncIterator[Buffer]
117
+
|AsyncIterable[Buffer]
118
+
|Iterator[Buffer]
119
+
|Iterable[Buffer],
90
120
*,
91
121
attributes: Attributes|None=None,
92
122
tags: Dict[str, str] |None=None,
@@ -97,5 +127,20 @@ async def put_async(
97
127
) ->PutResult:
98
128
"""Call `put` asynchronously.
99
129
100
-
Refer to the documentation for [put][obstore.put].
130
+
Refer to the documentation for [`put`][obstore.put]. In addition to what the
131
+
synchronous `put` allows for the `file` parameter, this **also supports an async
132
+
iterator or iterable** of objects implementing the Python buffer protocol.
133
+
134
+
This means, for example, you can pass the result of `get_async` directly to
135
+
`put_async`, and the request will be streamed through Python during the put
136
+
operation:
137
+
138
+
```py
139
+
import obstore as obs
140
+
141
+
# This only constructs the stream, it doesn't materialize the data in memory
142
+
resp = await obs.get_async(store1, path1)
143
+
# A streaming upload is created to copy the file to path2
0 commit comments