From d059619e5e33a96212dbe7af9e0575e82a6fd93b Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Thu, 18 Apr 2024 03:42:10 -0700 Subject: [PATCH] Make email attachments' names simpler (#208) --- skyvern/forge/sdk/workflow/models/block.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py index f25220e3..91886fac 100644 --- a/skyvern/forge/sdk/workflow/models/block.py +++ b/skyvern/forge/sdk/workflow/models/block.py @@ -9,7 +9,6 @@ from enum import StrEnum from pathlib import Path from tempfile import NamedTemporaryFile from typing import Annotated, Any, Literal, Union -from urllib.parse import urlparse import filetype import structlog @@ -822,10 +821,11 @@ class SendEmailBlock(Block): 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}"