From 1abe74579081dc20ef76c7423c4e146dd7f65752 Mon Sep 17 00:00:00 2001 From: harisreedhar Date: Sat, 17 Jan 2026 00:21:11 +0530 Subject: [PATCH] upload asset endpoint --- facefusion/apis/endpoints/assets.py | 22 ++++++++++++---------- tests/test_api_assets.py | 22 ---------------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/facefusion/apis/endpoints/assets.py b/facefusion/apis/endpoints/assets.py index 7203f5f1..a19bd8b9 100644 --- a/facefusion/apis/endpoints/assets.py +++ b/facefusion/apis/endpoints/assets.py @@ -59,17 +59,19 @@ async def prepare_files(files : List[UploadFile]) -> List[Tuple[str, MediaType]] temp_file.write(content) file_path = temp_file.name - if is_audio(file_path): - prepared_files.append((file_path, 'audio')) - continue - if is_image(file_path): - prepared_files.append((file_path, 'image')) - continue - if is_video(file_path): - prepared_files.append((file_path, 'video')) - continue + media_type : MediaType | None = None - if is_file(file_path): + if is_audio(file_path): + media_type = 'audio' + if is_image(file_path): + media_type = 'image' + if is_video(file_path): + media_type = 'video' + + if media_type: + prepared_files.append((file_path, media_type)) + + if not media_type and is_file(file_path): remove_file(file_path) return prepared_files diff --git a/tests/test_api_assets.py b/tests/test_api_assets.py index e0eb2c0f..1ab32789 100644 --- a/tests/test_api_assets.py +++ b/tests/test_api_assets.py @@ -120,28 +120,6 @@ def test_upload_target_asset(test_client : TestClient) -> None: assert upload_response.json().get('asset_id') -def test_upload_target_multiple_files_uses_first(test_client : TestClient) -> None: - create_session_response = test_client.post('/session', json = - { - 'client_version': metadata.get('version') - }) - create_session_body = create_session_response.json() - - with open('.assets/examples/target-240p.mp4', 'rb') as target_file_1: - with open('.assets/examples/target-240p.mp4', 'rb') as target_file_2: - upload_response = test_client.post('/assets?type=target', headers = - { - 'Authorization': 'Bearer ' + create_session_body.get('access_token') - }, files = - [ - ('file', ('target1.mp4', target_file_1, 'video/mp4')), - ('file', ('target2.mp4', target_file_2, 'video/mp4')) - ]) - - assert upload_response.status_code == 201 - assert upload_response.json().get('asset_id') - - def test_upload_unsupported_format(test_client : TestClient) -> None: create_session_response = test_client.post('/session', json = {