@@ -615,32 +615,43 @@ def upload_bytes(
615615 data : bytes ,
616616 serverpath : str ,
617617 datemodified : datetime .datetime = datetime .datetime .now (),
618+ nofileoverwrite : Optional [bool ] = False ,
619+ iflastmodified : Optional [datetime .datetime ] = None ,
618620 progress : Optional [Progress ] = None ,
619621 ) -> None :
620622 """
621623 Upload bytes 'data' to server at 'serverpath'.
622624 """
623- self .upload (BufferedReader (BytesIO (data )), serverpath , datemodified , progress = progress ) # type: ignore
625+ self .upload (BufferedReader (BytesIO (data )), serverpath , datemodified , nofileoverwrite = nofileoverwrite , iflastmodified = iflastmodified , progress = progress ) # type: ignore
624626
625627 def upload_str (
626628 self ,
627629 data : str ,
628630 serverpath : str ,
629631 datemodified : datetime .datetime = datetime .datetime .now (),
632+ nofileoverwrite : Optional [bool ] = False ,
633+ iflastmodified : Optional [datetime .datetime ] = None ,
630634 progress : Optional [Progress ] = None ,
631635 ) -> None :
632636 """
633637 Upload str 'data' UTF-8 encoded to server at 'serverpath'.
634638 """
635639 self .upload_bytes (
636- data .encode ("utf-8" ), serverpath , datemodified , progress = progress
640+ data .encode ("utf-8" ),
641+ serverpath ,
642+ datemodified ,
643+ nofileoverwrite = nofileoverwrite ,
644+ iflastmodified = iflastmodified ,
645+ progress = progress ,
637646 )
638647
639648 def upload_file (
640649 self ,
641650 localpath : pathlib .Path ,
642651 serverpath : str ,
643652 datemodified : datetime .datetime = datetime .datetime .now (),
653+ nofileoverwrite : Optional [bool ] = False ,
654+ iflastmodified : Optional [datetime .datetime ] = None ,
644655 adminproxyuserid : Optional [str ] = None ,
645656 progress : Optional [Progress ] = None ,
646657 ) -> None :
@@ -652,6 +663,8 @@ def upload_file(
652663 uploadf ,
653664 serverpath ,
654665 datemodified ,
666+ nofileoverwrite ,
667+ iflastmodified ,
655668 adminproxyuserid = adminproxyuserid ,
656669 progress = progress ,
657670 )
@@ -671,7 +684,7 @@ def upload(
671684 uploadf : BufferedReader ,
672685 serverpath : str ,
673686 datemodified : datetime .datetime ,
674- nofileoverwrite : bool = False ,
687+ nofileoverwrite : Optional [ bool ] = False ,
675688 iflastmodified : Optional [datetime .datetime ] = None ,
676689 adminproxyuserid : Optional [str ] = None ,
677690 progress : Optional [Progress ] = None ,
@@ -801,11 +814,14 @@ def close(self):
801814 "filesize" : 0 ,
802815 "date" : self ._serverdatetime (datemodified ),
803816 "adminproxyuserid" : adminproxyuserid ,
804- "nofileoverwrite" : nofileoverwrite ,
805- "iflastmodified" : (
806- self ._serverdatetime (iflastmodified ) if iflastmodified else None
807- ),
808817 }
818+
819+ if nofileoverwrite is not None :
820+ params ["nofileoverwrite" ] = "true" if nofileoverwrite else "false"
821+
822+ if iflastmodified is not None :
823+ params ["iflastmodified" ] = self ._serverdatetime (iflastmodified )
824+
809825 params_str = urlencode (params )
810826
811827 if params_str .find ("%2FSHARED%2F%21" ):
@@ -846,12 +862,14 @@ def close(self):
846862 "filename" : name ,
847863 "date" : self ._serverdatetime (datemodified ),
848864 "adminproxyuserid" : adminproxyuserid ,
849- "nofileoverwrite" : nofileoverwrite ,
850- "iflastmodified" : (
851- self ._serverdatetime (iflastmodified ) if iflastmodified else None
852- ),
853865 }
854866
867+ if nofileoverwrite is not None :
868+ params ["nofileoverwrite" ] = "true" if nofileoverwrite else "false"
869+
870+ if iflastmodified is not None :
871+ params ["iflastmodified" ] = self ._serverdatetime (iflastmodified )
872+
855873 if data_size is not None :
856874 params ["filesize" ] = data_size
857875
0 commit comments