@@ -993,6 +993,99 @@ def download_file(
993993 )
994994
995995
996+ def upload_project_file (
997+ project_name : str ,
998+ filepath : str ,
999+ * ,
1000+ content_type : Optional [str ] = None ,
1001+ filename : Optional [str ] = None ,
1002+ file_id : Optional [str ] = None ,
1003+ activity_id : Optional [str ] = None ,
1004+ chunk_size : Optional [int ] = None ,
1005+ progress : Optional [TransferProgress ] = None ,
1006+ ) -> requests .Response :
1007+ """Upload project file from a filepath.
1008+
1009+ Project files are usually binary files, such as images, videos,
1010+ or other media files that can be accessed via api endpoint
1011+ '{server url}/api/projects/{project_name}/files/{file_id}'.
1012+
1013+ Args:
1014+ project_name (str): Project name.
1015+ filepath (str): Path where file will be downloaded.
1016+ content_type (Optional[str]): MIME type of file.
1017+ filename (Optional[str]): Server filename, filename from filepath
1018+ is used if not passed.
1019+ file_id (Optional[str]): File id.
1020+ activity_id (Optional[str]): To which activity is file related.
1021+ chunk_size (Optional[int]): Size of chunks that are received
1022+ in single loop.
1023+ progress (Optional[TransferProgress]): Object that gives ability
1024+ to track download progress.
1025+
1026+ Returns:
1027+ requests.Response: Requests response.
1028+
1029+ """
1030+ con = get_server_api_connection ()
1031+ return con .upload_project_file (
1032+ project_name = project_name ,
1033+ filepath = filepath ,
1034+ content_type = content_type ,
1035+ filename = filename ,
1036+ file_id = file_id ,
1037+ activity_id = activity_id ,
1038+ chunk_size = chunk_size ,
1039+ progress = progress ,
1040+ )
1041+
1042+
1043+ def upload_project_file_from_stream (
1044+ project_name : str ,
1045+ stream : StreamType ,
1046+ filename : str ,
1047+ * ,
1048+ content_type : Optional [str ] = None ,
1049+ file_id : Optional [str ] = None ,
1050+ activity_id : Optional [str ] = None ,
1051+ chunk_size : Optional [int ] = None ,
1052+ progress : Optional [TransferProgress ] = None ,
1053+ ) -> requests .Response :
1054+ """Upload project file from a filepath.
1055+
1056+ Project files are usually binary files, such as images, videos,
1057+ or other media files that can be accessed via api endpoint
1058+ '{server url}/api/projects/{project_name}/files/{file_id}'.
1059+
1060+ Args:
1061+ project_name (str): Project name.
1062+ stream (StreamType): Stream used as source for upload.
1063+ filename (str): Name of file on server.
1064+ content_type (Optional[str]): MIME type of file.
1065+ file_id (Optional[str]): File id.
1066+ activity_id (Optional[str]): To which activity is file related.
1067+ chunk_size (Optional[int]): Size of chunks that are received
1068+ in single loop.
1069+ progress (Optional[TransferProgress]): Object that gives ability
1070+ to track download progress.
1071+
1072+ Returns:
1073+ requests.Response: Requests response.
1074+
1075+ """
1076+ con = get_server_api_connection ()
1077+ return con .upload_project_file_from_stream (
1078+ project_name = project_name ,
1079+ stream = stream ,
1080+ filename = filename ,
1081+ content_type = content_type ,
1082+ file_id = file_id ,
1083+ activity_id = activity_id ,
1084+ chunk_size = chunk_size ,
1085+ progress = progress ,
1086+ )
1087+
1088+
9961089def download_project_file (
9971090 project_name : str ,
9981091 file_id : str ,
@@ -1067,11 +1160,27 @@ def download_project_file_to_stream(
10671160 )
10681161
10691162
1163+ def delete_project_file (
1164+ project_name : str ,
1165+ file_id : str ,
1166+ ) -> None :
1167+ """Delete project file.
1168+ """
1169+ con = get_server_api_connection ()
1170+ return con .delete_project_file (
1171+ project_name = project_name ,
1172+ file_id = file_id ,
1173+ )
1174+
1175+
10701176def upload_file_from_stream (
10711177 endpoint : str ,
10721178 stream : StreamType ,
10731179 progress : Optional [TransferProgress ] = None ,
10741180 request_type : Optional [RequestType ] = None ,
1181+ * ,
1182+ content_type : Optional [str ] = None ,
1183+ filename : Optional [str ] = None ,
10751184 ** kwargs ,
10761185) -> requests .Response :
10771186 """Upload file to server from bytes.
@@ -1087,6 +1196,8 @@ def upload_file_from_stream(
10871196 to track upload progress.
10881197 request_type (Optional[RequestType]): Type of request that will
10891198 be used to upload file.
1199+ content_type (Optional[str]): MIME type of the file.
1200+ filename (Optional[str]): Filename of file on server.
10901201 **kwargs (Any): Additional arguments that will be passed
10911202 to request function.
10921203
@@ -1100,6 +1211,8 @@ def upload_file_from_stream(
11001211 stream = stream ,
11011212 progress = progress ,
11021213 request_type = request_type ,
1214+ content_type = content_type ,
1215+ filename = filename ,
11031216 ** kwargs ,
11041217 )
11051218
@@ -1109,6 +1222,9 @@ def upload_file(
11091222 filepath : str ,
11101223 progress : Optional [TransferProgress ] = None ,
11111224 request_type : Optional [RequestType ] = None ,
1225+ * ,
1226+ content_type : Optional [str ] = None ,
1227+ filename : Optional [str ] = None ,
11121228 ** kwargs ,
11131229) -> requests .Response :
11141230 """Upload file to server.
@@ -1124,6 +1240,8 @@ def upload_file(
11241240 to track upload progress.
11251241 request_type (Optional[RequestType]): Type of request that will
11261242 be used to upload file.
1243+ content_type (Optional[str]): MIME type of the file.
1244+ filename (Optional[str]): Filename of file on server.
11271245 **kwargs (Any): Additional arguments that will be passed
11281246 to request function.
11291247
@@ -1137,6 +1255,8 @@ def upload_file(
11371255 filepath = filepath ,
11381256 progress = progress ,
11391257 request_type = request_type ,
1258+ content_type = content_type ,
1259+ filename = filename ,
11401260 ** kwargs ,
11411261 )
11421262
0 commit comments