@@ -616,32 +616,43 @@ def upload_bytes(
616616 data : bytes ,
617617 serverpath : str ,
618618 datemodified : datetime .datetime = datetime .datetime .now (),
619+ nofileoverwrite : Optional [bool ] = False ,
620+ iflastmodified : Optional [datetime .datetime ] = None ,
619621 progress : Optional [Progress ] = None ,
620622 ) -> None :
621623 """
622624 Upload bytes 'data' to server at 'serverpath'.
623625 """
624- self .upload (BufferedReader (BytesIO (data )), serverpath , datemodified , progress = progress ) # type: ignore
626+ self .upload (BufferedReader (BytesIO (data )), serverpath , datemodified , nofileoverwrite = nofileoverwrite , iflastmodified = iflastmodified , progress = progress ) # type: ignore
625627
626628 def upload_str (
627629 self ,
628630 data : str ,
629631 serverpath : str ,
630632 datemodified : datetime .datetime = datetime .datetime .now (),
633+ nofileoverwrite : Optional [bool ] = False ,
634+ iflastmodified : Optional [datetime .datetime ] = None ,
631635 progress : Optional [Progress ] = None ,
632636 ) -> None :
633637 """
634638 Upload str 'data' UTF-8 encoded to server at 'serverpath'.
635639 """
636640 self .upload_bytes (
637- data .encode ("utf-8" ), serverpath , datemodified , progress = progress
641+ data .encode ("utf-8" ),
642+ serverpath ,
643+ datemodified ,
644+ nofileoverwrite = nofileoverwrite ,
645+ iflastmodified = iflastmodified ,
646+ progress = progress ,
638647 )
639648
640649 def upload_file (
641650 self ,
642651 localpath : pathlib .Path ,
643652 serverpath : str ,
644653 datemodified : datetime .datetime = datetime .datetime .now (),
654+ nofileoverwrite : Optional [bool ] = False ,
655+ iflastmodified : Optional [datetime .datetime ] = None ,
645656 adminproxyuserid : Optional [str ] = None ,
646657 progress : Optional [Progress ] = None ,
647658 ) -> None :
@@ -653,6 +664,8 @@ def upload_file(
653664 uploadf ,
654665 serverpath ,
655666 datemodified ,
667+ nofileoverwrite ,
668+ iflastmodified ,
656669 adminproxyuserid = adminproxyuserid ,
657670 progress = progress ,
658671 )
@@ -672,6 +685,8 @@ def upload(
672685 uploadf : BufferedReader ,
673686 serverpath : str ,
674687 datemodified : datetime .datetime ,
688+ nofileoverwrite : Optional [bool ] = False ,
689+ iflastmodified : Optional [datetime .datetime ] = None ,
675690 adminproxyuserid : Optional [str ] = None ,
676691 progress : Optional [Progress ] = None ,
677692 ) -> None :
@@ -801,6 +816,13 @@ def close(self):
801816 "date" : self ._serverdatetime (datemodified ),
802817 "adminproxyuserid" : adminproxyuserid ,
803818 }
819+
820+ if nofileoverwrite is not None :
821+ params ["nofileoverwrite" ] = 1 if nofileoverwrite else 0
822+
823+ if iflastmodified is not None :
824+ params ["iflastmodified" ] = str (int (iflastmodified .timestamp ()))
825+
804826 params_str = urlencode (params )
805827
806828 if params_str .find ("%2FSHARED%2F%21" ):
@@ -843,6 +865,12 @@ def close(self):
843865 "adminproxyuserid" : adminproxyuserid ,
844866 }
845867
868+ if nofileoverwrite is not None :
869+ params ["nofileoverwrite" ] = 1 if nofileoverwrite else 0
870+
871+ if iflastmodified is not None :
872+ params ["iflastmodified" ] = str (int (iflastmodified .timestamp ()))
873+
846874 if data_size is not None :
847875 params ["filesize" ] = data_size
848876
@@ -903,6 +931,34 @@ def share(self, path: str, adminproxyuserid: str = "") -> FCShare:
903931 str_to_bool (resp .findtext ("./share/allowpublicuploadonly" , "" )),
904932 )
905933
934+ def quickshare (self , sharelocation : str , adminproxyuserid : str = "" ) -> FCShare :
935+ """
936+ Quick Share 'sharelocation'
937+ """
938+ resp = self ._api_call (
939+ "/core/quickshare" ,
940+ {"sharelocation" : sharelocation , "adminproxyuserid" : adminproxyuserid },
941+ )
942+
943+ shareid = resp .findtext ("./share/shareid" , "" )
944+
945+ if not shareid :
946+ msg = resp .findtext ("./meta/message" , "" )
947+ if msg :
948+ raise ServerError ("" , msg )
949+ else :
950+ raise ServerError ("" , "No shareid in response" )
951+
952+ return FCShare (
953+ shareid ,
954+ resp .findtext ("./share/sharename" , "" ),
955+ resp .findtext ("./share/sharelocation" , "" ),
956+ str_to_bool (resp .findtext ("./share/allowpublicaccess" , "" )),
957+ str_to_bool (resp .findtext ("./share/allowpublicupload" , "" )),
958+ str_to_bool (resp .findtext ("./share/allowpublicviewonly" , "" )),
959+ str_to_bool (resp .findtext ("./share/allowpublicuploadonly" , "" )),
960+ )
961+
906962 def getshareforpath (self , path : str , adminproxyuserid : str = "" ) -> FCShare :
907963 """
908964 Share 'path'
@@ -971,6 +1027,15 @@ def adduserstoshare(
9711027
9721028 self ._raise_exception_from_command (resp )
9731029
1030+ def addgrouptoshare (self , share : FCShare , groupid : str ) -> None :
1031+ """
1032+ Allow group access to share
1033+ """
1034+ resp = self ._api_call (
1035+ "/core/addgrouptoshare" , {"shareid" : share .shareid , "groupid" : groupid }
1036+ )
1037+ self ._raise_exception_from_command (resp )
1038+
9741039 def createfolder (
9751040 self ,
9761041 path : str ,
@@ -1044,6 +1109,35 @@ def setuseraccessforshare(
10441109 )
10451110 self ._raise_exception_from_command (resp )
10461111
1112+ def setgroupaccessforshare (
1113+ self ,
1114+ share : FCShare ,
1115+ groupid : str ,
1116+ allowwrite : bool ,
1117+ allowdownload : bool ,
1118+ allowshare : bool ,
1119+ allowsync : bool ,
1120+ disallowdelete : bool ,
1121+ adminproxyuserid : Optional [str ] = None ,
1122+ ) -> None :
1123+ """
1124+ Set group permissions for share
1125+ """
1126+ resp = self ._api_call (
1127+ "/core/setgroupaccessforshare" ,
1128+ {
1129+ "shareid" : share .shareid ,
1130+ "groupid" : groupid ,
1131+ "write" : "true" if allowwrite else "false" ,
1132+ "download" : "true" if allowdownload else "false" ,
1133+ "share" : "true" if allowshare else "false" ,
1134+ "sync" : "true" if allowsync else "false" ,
1135+ "disallowdelete" : "true" if disallowdelete else "false" ,
1136+ "adminproxyuserid" : adminproxyuserid if adminproxyuserid else "" ,
1137+ },
1138+ )
1139+ self ._raise_exception_from_command (resp )
1140+
10471141 def getusersforshare (self , share : FCShare ) -> list [FCShareUser ]:
10481142 """
10491143 Returns a list of users that are added explicitly to the share
@@ -1585,7 +1679,7 @@ def get_config_settings(self, config: list[str]) -> None:
15851679 config_opts [param_key ] = config [i ]
15861680
15871681 resp = self ._api_call (
1588- "/admin/setconfigsetting " ,
1682+ "/admin/getconfigsetting " ,
15891683 {
15901684 "count" : str (len (config_opts )),
15911685 ** {f"param{ i } " : value for i , value in enumerate (config_opts )},
0 commit comments