Skip to content

Commit f5fd48c

Browse files
author
Kostiantyn Feferman
committed
Add ifetag parameter to upload function
1 parent 4140852 commit f5fd48c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

filecloudapi/fcserver.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,12 @@ def upload_bytes(
634634
nofileoverwrite: Optional[bool] = False,
635635
iflastmodified: Optional[datetime.datetime] = None,
636636
progress: Optional[Progress] = None,
637+
ifetag: Optional[str] = None,
637638
) -> ETag:
638639
"""
639640
Upload bytes 'data' to server at 'serverpath'.
640641
"""
641-
return self.upload(BufferedReader(BytesIO(data)), serverpath, datemodified, nofileoverwrite=nofileoverwrite, iflastmodified=iflastmodified, progress=progress) # type: ignore
642+
return self.upload(BufferedReader(BytesIO(data)), serverpath, datemodified, nofileoverwrite=nofileoverwrite, iflastmodified=iflastmodified, progress=progress, ifetag=ifetag) # type: ignore
642643

643644
def upload_str(
644645
self,
@@ -648,6 +649,7 @@ def upload_str(
648649
nofileoverwrite: Optional[bool] = False,
649650
iflastmodified: Optional[datetime.datetime] = None,
650651
progress: Optional[Progress] = None,
652+
ifetag: Optional[str] = None,
651653
) -> ETag:
652654
"""
653655
Upload str 'data' UTF-8 encoded to server at 'serverpath'.
@@ -659,6 +661,7 @@ def upload_str(
659661
nofileoverwrite=nofileoverwrite,
660662
iflastmodified=iflastmodified,
661663
progress=progress,
664+
ifetag=ifetag
662665
)
663666

664667
def upload_file(
@@ -670,6 +673,7 @@ def upload_file(
670673
iflastmodified: Optional[datetime.datetime] = None,
671674
adminproxyuserid: Optional[str] = None,
672675
progress: Optional[Progress] = None,
676+
ifetag: Optional[str] = None,
673677
) -> ETag:
674678
"""
675679
Upload file at 'localpath' to server at 'serverpath'.
@@ -683,6 +687,7 @@ def upload_file(
683687
iflastmodified,
684688
adminproxyuserid=adminproxyuserid,
685689
progress=progress,
690+
ifetag=ifetag
686691
)
687692

688693
def _serverdatetime(self, dt: datetime.datetime):
@@ -704,6 +709,7 @@ def upload(
704709
iflastmodified: Optional[datetime.datetime] = None,
705710
adminproxyuserid: Optional[str] = None,
706711
progress: Optional[Progress] = None,
712+
ifetag: Optional[str] = None,
707713
) -> ETag:
708714
"""
709715
Upload seekable stream at uploadf to server at 'serverpath'
@@ -838,6 +844,9 @@ def close(self):
838844
if iflastmodified is not None:
839845
params["iflastmodified"] = str(int(iflastmodified.timestamp()))
840846

847+
if ifetag is not None:
848+
params["ifetag"] = ifetag
849+
841850
params_str = urlencode(params)
842851

843852
if params_str.find("%2FSHARED%2F%21"):
@@ -887,6 +896,9 @@ def close(self):
887896
if iflastmodified is not None:
888897
params["iflastmodified"] = str(int(iflastmodified.timestamp()))
889898

899+
if ifetag is not None:
900+
params["ifetag"] = ifetag
901+
890902
if data_size is not None:
891903
params["filesize"] = data_size
892904

0 commit comments

Comments
 (0)