From 4aadc95d59efef52610cffeb16d55d68bc75ecd7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:47:04 +0100 Subject: [PATCH 1/2] added helper upload methods for project files --- ayon_api/server_api.py | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/ayon_api/server_api.py b/ayon_api/server_api.py index 65b6faa15..03086e050 100644 --- a/ayon_api/server_api.py +++ b/ayon_api/server_api.py @@ -1517,6 +1517,74 @@ def download_file( return progress + def upload_project_file( + self, + project_name: str, + filepath: str, + *, + chunk_size: Optional[int] = None, + progress: Optional[TransferProgress] = None, + ) -> requests.Response: + """Upload project file from a filepath. + + Project files are usually binary files, such as images, videos, + or other media files that can be accessed via api endpoint + '{server url}/api/projects/{project_name}/files/{file_id}'. + + Args: + project_name (str): Project name. + filepath (str): Path where file will be downloaded. + chunk_size (Optional[int]): Size of chunks that are received + in single loop. + progress (Optional[TransferProgress]): Object that gives ability + to track download progress. + + Returns: + requests.Response: Requests response. + + """ + return self.upload_file( + f"api/projects/{project_name}/files", + filepath, + chunk_size=chunk_size, + progress=progress, + request_type=RequestTypes.post, + ) + + def upload_project_file_from_stream( + self, + project_name: str, + stream: StreamType, + *, + chunk_size: Optional[int] = None, + progress: Optional[TransferProgress] = None, + ) -> requests.Response: + """Upload project file from a filepath. + + Project files are usually binary files, such as images, videos, + or other media files that can be accessed via api endpoint + '{server url}/api/projects/{project_name}/files/{file_id}'. + + Args: + project_name (str): Project name. + stream (StreamType): Stream used as source for upload. + chunk_size (Optional[int]): Size of chunks that are received + in single loop. + progress (Optional[TransferProgress]): Object that gives ability + to track download progress. + + Returns: + requests.Response: Requests response. + + """ + return self.upload_file_from_stream( + f"api/projects/{project_name}/files", + stream, + chunk_size=chunk_size, + progress=progress, + request_type=RequestTypes.post, + ) + def download_project_file( self, project_name: str, From a090ba4855c3b5234745aaaef393cb73ed9a878e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:47:30 +0100 Subject: [PATCH 2/2] add new functions to public api --- ayon_api/__init__.py | 4 +++ ayon_api/_api.py | 68 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/ayon_api/__init__.py b/ayon_api/__init__.py index c43bfcdb1..ae73d2090 100644 --- a/ayon_api/__init__.py +++ b/ayon_api/__init__.py @@ -70,6 +70,8 @@ delete, download_file_to_stream, download_file, + upload_project_file, + upload_project_file_from_stream, download_project_file, download_project_file_to_stream, upload_file_from_stream, @@ -351,6 +353,8 @@ "delete", "download_file_to_stream", "download_file", + "upload_project_file", + "upload_project_file_from_stream", "download_project_file", "download_project_file_to_stream", "upload_file_from_stream", diff --git a/ayon_api/_api.py b/ayon_api/_api.py index 06ece19b0..6c1ba45bc 100644 --- a/ayon_api/_api.py +++ b/ayon_api/_api.py @@ -993,6 +993,74 @@ def download_file( ) +def upload_project_file( + project_name: str, + filepath: str, + *, + chunk_size: Optional[int] = None, + progress: Optional[TransferProgress] = None, +) -> requests.Response: + """Upload project file from a filepath. + + Project files are usually binary files, such as images, videos, + or other media files that can be accessed via api endpoint + '{server url}/api/projects/{project_name}/files/{file_id}'. + + Args: + project_name (str): Project name. + filepath (str): Path where file will be downloaded. + chunk_size (Optional[int]): Size of chunks that are received + in single loop. + progress (Optional[TransferProgress]): Object that gives ability + to track download progress. + + Returns: + requests.Response: Requests response. + + """ + con = get_server_api_connection() + return con.upload_project_file( + project_name=project_name, + filepath=filepath, + chunk_size=chunk_size, + progress=progress, + ) + + +def upload_project_file_from_stream( + project_name: str, + stream: StreamType, + *, + chunk_size: Optional[int] = None, + progress: Optional[TransferProgress] = None, +) -> requests.Response: + """Upload project file from a filepath. + + Project files are usually binary files, such as images, videos, + or other media files that can be accessed via api endpoint + '{server url}/api/projects/{project_name}/files/{file_id}'. + + Args: + project_name (str): Project name. + stream (StreamType): Stream used as source for upload. + chunk_size (Optional[int]): Size of chunks that are received + in single loop. + progress (Optional[TransferProgress]): Object that gives ability + to track download progress. + + Returns: + requests.Response: Requests response. + + """ + con = get_server_api_connection() + return con.upload_project_file_from_stream( + project_name=project_name, + stream=stream, + chunk_size=chunk_size, + progress=progress, + ) + + def download_project_file( project_name: str, file_id: str,