Skip to content

Commit 936b71b

Browse files
committed
put_object: add append object support
Signed-off-by: Bala.FA <[email protected]>
1 parent f7e047b commit 936b71b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

minio/api.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,8 @@ def put_object(
18351835
num_parallel_uploads: int = 3,
18361836
tags: Tags | None = None,
18371837
retention: Retention | None = None,
1838-
legal_hold: bool = False
1838+
legal_hold: bool = False,
1839+
write_offset: int | None = None,
18391840
) -> ObjectWriteResult:
18401841
"""
18411842
Uploads data from a stream to an object in a bucket.
@@ -1854,6 +1855,7 @@ def put_object(
18541855
:param tags: :class:`Tags` for the object.
18551856
:param retention: :class:`Retention` configuration object.
18561857
:param legal_hold: Flag to set legal hold for the object.
1858+
:param write_offset: Offset byte for appending data to existing object.
18571859
:return: :class:`ObjectWriteResult` object.
18581860
18591861
Example::
@@ -1890,13 +1892,21 @@ def put_object(
18901892
raise ValueError("retention must be Retention type")
18911893
if not callable(getattr(data, "read")):
18921894
raise ValueError("input data must have callable read()")
1895+
if write_offset is not None:
1896+
if write_offset < 0:
1897+
raise ValueError("write offset should not be negative")
1898+
if length < 0:
1899+
raise ValueError("length must be provided for write offset")
1900+
part_size = length if length > MIN_PART_SIZE else MIN_PART_SIZE
18931901
part_size, part_count = get_part_info(length, part_size)
18941902
if progress:
18951903
# Set progress bar length and object name before upload
18961904
progress.set_meta(object_name=object_name, total_length=length)
18971905

18981906
headers = genheaders(metadata, sse, tags, retention, legal_hold)
18991907
headers["Content-Type"] = content_type or "application/octet-stream"
1908+
if write_offset:
1909+
headers["x-amz-write-offset-bytes"] = str(write_offset)
19001910

19011911
object_size = length
19021912
uploaded_size = 0

0 commit comments

Comments
 (0)