@@ -1835,7 +1835,8 @@ def put_object(
1835
1835
num_parallel_uploads : int = 3 ,
1836
1836
tags : Tags | None = None ,
1837
1837
retention : Retention | None = None ,
1838
- legal_hold : bool = False
1838
+ legal_hold : bool = False ,
1839
+ write_offset : int | None = None ,
1839
1840
) -> ObjectWriteResult :
1840
1841
"""
1841
1842
Uploads data from a stream to an object in a bucket.
@@ -1854,6 +1855,7 @@ def put_object(
1854
1855
:param tags: :class:`Tags` for the object.
1855
1856
:param retention: :class:`Retention` configuration object.
1856
1857
:param legal_hold: Flag to set legal hold for the object.
1858
+ :param write_offset: Offset byte for appending data to existing object.
1857
1859
:return: :class:`ObjectWriteResult` object.
1858
1860
1859
1861
Example::
@@ -1890,13 +1892,21 @@ def put_object(
1890
1892
raise ValueError ("retention must be Retention type" )
1891
1893
if not callable (getattr (data , "read" )):
1892
1894
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
1893
1901
part_size , part_count = get_part_info (length , part_size )
1894
1902
if progress :
1895
1903
# Set progress bar length and object name before upload
1896
1904
progress .set_meta (object_name = object_name , total_length = length )
1897
1905
1898
1906
headers = genheaders (metadata , sse , tags , retention , legal_hold )
1899
1907
headers ["Content-Type" ] = content_type or "application/octet-stream"
1908
+ if write_offset :
1909
+ headers ["x-amz-write-offset-bytes" ] = str (write_offset )
1900
1910
1901
1911
object_size = length
1902
1912
uploaded_size = 0
0 commit comments