From 8446d83896e17efe8518bb91a0ec43a1e90b5f8a Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 11 Apr 2024 23:36:40 +0700 Subject: [PATCH] fix --- chain_service/services/file_uploader.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/chain_service/services/file_uploader.py b/chain_service/services/file_uploader.py index 9796dca..937ab7f 100644 --- a/chain_service/services/file_uploader.py +++ b/chain_service/services/file_uploader.py @@ -41,13 +41,19 @@ class FileUploaderService: if uploaded_file: return - converted_content = await self.audio_converter_service.audio_to_ogg( - audio=BytesIO((await self.client.get(file_url)).read()) - ) + if file_url.endswith(".ogg") or file_url.endswith(".mp3"): + content = await self.audio_converter_service.audio_to_ogg( + audio=BytesIO((await self.client.get(file_url)).read()) + ) - uploaded_file_id = await self.planfix_client.upload_file( - file_content=converted_content - ) + uploaded_file_id = await self.planfix_client.upload_file( + file_content=content + ) + + else: + uploaded_file_id = await self.planfix_client.upload_file_from_url( + file_url + ) await self.uploaded_file_repository.upsert( UploadedFile(file_id=uploaded_file_id, file_url=file_url)