Skip to content

Commit

Permalink
Make email attachments' names simpler (Skyvern-AI#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy committed Apr 18, 2024
1 parent 8f78b95 commit e7314ef
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit e7314ef

Please sign in to comment.