MCPcopy
hub / github.com/httpie/cli / process_file_upload_arg

Function process_file_upload_arg

httpie/cli/requestitems.py:150–162  ·  view source on GitHub ↗
(arg: KeyValueArg)

Source from the content-addressed store, hash-verified

148
149
150def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]:
151 parts = arg.value.split(SEPARATOR_FILE_UPLOAD_TYPE)
152 filename = parts[0]
153 mime_type = parts[1] if len(parts) > 1 else None
154 try:
155 f = open(os.path.expanduser(filename), 'rb')
156 except OSError as e:
157 raise ParseError(f'{arg.orig!r}: {e}')
158 return (
159 os.path.basename(filename),
160 f,
161 mime_type or get_content_type(filename),
162 )
163
164
165def convert_json_value_to_form_if_needed(in_json_mode: bool, processor: Callable[[KeyValueArg], JSONType]) -> Callable[[], str]:

Callers

nothing calls this directly

Calls 2

ParseErrorClass · 0.85
get_content_typeFunction · 0.85

Tested by

no test coverage detected