upload asset endpoint

This commit is contained in:
harisreedhar
2026-01-17 00:21:11 +05:30
committed by henryruhs
parent 6f66937e72
commit 1abe745790
2 changed files with 12 additions and 32 deletions
+12 -10
View File
@@ -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
-22
View File
@@ -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 =
{