Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make email attachments' names simpler #208

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions skyvern/forge/sdk/workflow/models/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Annotated, Any, Literal, Union
from urllib.parse import urlparse

import filetype
import structlog
Expand Down Expand Up @@ -822,10 +821,11 @@ async def _build_email_message(
extension = None

maintype, subtype = ctype.split("/", 1)
attachment_filename = urlparse(filename).path.replace("/", "_")
attachment_path = Path(path)
attachment_filename = attachment_path.name

# Check if the filename has an extension
if not Path(attachment_filename).suffix:
if not attachment_path.suffix:
# If no extension, guess it based on the MIME type
if extension:
attachment_filename += f".{extension}"
Expand Down
Loading