Skip to content

Commit a8e8d65

Browse files
author
Alex Kwiatkowski
committed
wip: add put_opts & put_multipart
1 parent 445e9d7 commit a8e8d65

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

object-store/python/object_store/__init__.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# of static code checkers. Thus we avoid listing them with __all__ = ...
66
from ._internal import ClientOptions as ClientOptions
77
from ._internal import ListResult as ListResult
8+
from ._internal import PutResult as PutResult
9+
from ._internal import MultipartUpload as MultipartUpload
810
from ._internal import ObjectMeta as ObjectMeta
911
from ._internal import ObjectStore as _ObjectStore
1012
from ._internal import Path as Path
@@ -80,7 +82,7 @@ def get_range(self, location: PathLike, start: int, length: int) -> bytes:
8082
"""
8183
return super().get_range(_as_path(location), start, length)
8284

83-
def put(self, location: PathLike, bytes: BytesLike) -> None:
85+
def put(self, location: PathLike, bytes: BytesLike) -> PutResult:
8486
"""Save the provided bytes to the specified location.
8587
8688
Args:
@@ -89,6 +91,23 @@ def put(self, location: PathLike, bytes: BytesLike) -> None:
8991
"""
9092
return super().put(_as_path(location), _as_bytes(bytes))
9193

94+
def put_opts(self, location: PathLike, bytes: BytesLike) -> PutResult:
95+
"""Save the provided bytes to the specified location with the given options
96+
97+
Args:
98+
location (PathLike): path / key to storage location
99+
bytes (BytesLike): data to be written to location
100+
"""
101+
return super().put_opts(_as_path(location), _as_bytes(bytes))
102+
103+
def put_multipart(self, location: PathLike) -> MultipartUpload:
104+
"""Perform a multipart upload
105+
106+
Args:
107+
location (PathLike): path / key to storage location
108+
"""
109+
return super().put_multipart(_as_path(location))
110+
92111
def delete(self, location: PathLike) -> None:
93112
"""Delete the object at the specified location.
94113

object-store/python/object_store/_internal.pyi

+27-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ class ListResult:
3232
def objects(self) -> list[ObjectMeta]:
3333
"""Object metadata for the listing"""
3434

35+
class PutResult:
36+
"""TODO..."""
37+
38+
# @property
39+
# def common_prefixes(self) -> list[Path]:
40+
# """Prefixes that are common (like directories)"""
41+
# @property
42+
# def objects(self) -> list[ObjectMeta]:
43+
# """Object metadata for the listing"""
44+
pass
45+
46+
class MultipartUpload:
47+
"""TODO..."""
48+
49+
# @property
50+
# def common_prefixes(self) -> list[Path]:
51+
# """Prefixes that are common (like directories)"""
52+
# @property
53+
# def objects(self) -> list[ObjectMeta]:
54+
# """Object metadata for the listing"""
55+
pass
56+
3557
class ClientOptions:
3658
"""HTTP client configuration for remote object stores"""
3759

@@ -133,8 +155,12 @@ class ObjectStore:
133155
"""Return the bytes that are stored at the specified location."""
134156
def get_range(self, location: Path, start: int, length: int) -> bytes:
135157
"""Return the bytes that are stored at the specified location in the given byte range."""
136-
def put(self, location: Path, bytes: bytes) -> None:
158+
def put(self, location: Path, bytes: bytes) -> PutResult:
137159
"""Save the provided bytes to the specified location."""
160+
def put_opts(self, location: Path, bytes: bytes) -> PutResult:
161+
"""Save the provided bytes to the specified location with the given options"""
162+
def put_multipart(self, location: Path) -> MultipartUpload:
163+
"""Perform a multipart upload"""
138164
def list(self, prefix: Path | None) -> list[ObjectMeta]:
139165
"""List all the objects with the given prefix.
140166

0 commit comments

Comments
 (0)