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)