feat: Include file extension in upload URLs

Append the file extension to the generated upload URL if available. This ensures the URL is more accurate and directly points to the file with its correct type, both at initial generation and after file processing completes.
This commit is contained in:
Slipstream 2025-05-21 12:25:09 -06:00
parent 47353d7c8b
commit 92e4deda5f
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -261,7 +261,9 @@ class UploadCog(commands.Cog, name="Upload"):
# Poll until access_ready is true or timeout after 30 seconds
file_id = upload_data.get("id", "unknown")
file_url = f"https://slipstreamm.dev/uploads/{file_id}"
file_extension = upload_data.get("file_extension", "")
# Append file extension to the URL if available
file_url = f"https://slipstreamm.dev/uploads/{file_id}" + (f".{file_extension}" if file_extension else "")
# Send initial message that we're waiting for the file to be processed
status_message = await interaction.followup.send("File uploaded successfully. Waiting for file processing to complete...")
@ -278,6 +280,9 @@ class UploadCog(commands.Cog, name="Upload"):
print(f"File is ready after {attempt+1} attempts")
# Update upload_data with the latest information
upload_data = file_status
# Update file_url with the latest file extension
file_extension = file_status.get("file_extension", "")
file_url = f"https://slipstreamm.dev/uploads/{file_id}" + (f".{file_extension}" if file_extension else "")
break
# Wait 1 second before polling again