mirror of
https://github.com/facefusion/facefusion.git
synced 2026-10-13 17:17:30 +02:00
upload asset endpoint
This commit is contained in:
1 parent
e3aa3d15f5
commit
746b3249ef
2 files changed
+12
-32
No files matched your search
@@ -59,17 +59,19 @@ async def prepare_files(files : List[UploadFile]) -> List[Tuple[str, MediaType]]
|
|||||||
temp_file.write(content)
|
temp_file.write(content)
|
||||||
file_path = temp_file.name
|
file_path = temp_file.name
|
||||||
|
|
||||||
if is_audio(file_path):
|
media_type : MediaType | None = None
|
||||||
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
|
|
||||||
|
|
||||||
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)
|
remove_file(file_path)
|
||||||
|
|
||||||
return prepared_files
|
return prepared_files
|
||||||
@@ -120,28 +120,6 @@ def test_upload_target_asset(test_client : TestClient) -> None:
|
|||||||
assert upload_response.json().get('asset_id')
|
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:
|
def test_upload_unsupported_format(test_client : TestClient) -> None:
|
||||||
create_session_response = test_client.post('/session', json =
|
create_session_response = test_client.post('/session', json =
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user