Skip to content

Commit

Permalink
make files optional
Browse files Browse the repository at this point in the history
  • Loading branch information
okigan committed Mar 14, 2024
1 parent fbbd052 commit dc25c12
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions awscurl/awscurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
import re

from typing import IO, List, Tuple, Union
from typing import IO, List, Optional, Tuple, Union
import urllib
from urllib.parse import quote

Expand Down Expand Up @@ -434,7 +434,7 @@ def load_aws_config(access_key, secret_key, security_token, credentials_path, pr
return access_key, secret_key, security_token


def __process_form_data(form_data: List[str]) -> List[Tuple[str, Union[str, Tuple[str, Union[IO, Tuple[IO, str]]]]]]:
def __process_form_data(form_data: List[str]) -> Optional[List[Tuple[str, Union[str, Tuple[str, Union[IO, Tuple[IO, str]]]]]]]:
"""
Process form data to prepare files for uploading with optional MIME types,
supporting specific form field names for each file.
Expand Down Expand Up @@ -462,6 +462,9 @@ def __process_form_data(form_data: List[str]) -> List[Tuple[str, Union[str, Tupl
(fieldname, filetuple), where 'filetuple' is either (filepath, fileobject)
or (filepath, (fileobject, mimetype)) if a MIME type is specified.
"""
if form_data is None:
return None

files = []
for file_arg in form_data:
# Splitting the argument into its components: field name, file path, and optional MIME type
Expand Down

0 comments on commit dc25c12

Please sign in to comment.