1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Add support for multipart upload streaming

Close #684, #201
This commit is contained in:
Jakub Roztocil
2020-08-15 17:50:00 +02:00
parent d32c8cab12
commit 6cd934d1b8
10 changed files with 86 additions and 12 deletions

View File

@@ -99,15 +99,13 @@ def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]:
parts = arg.value.split(SEPARATOR_FILE_UPLOAD_TYPE)
filename = parts[0]
mime_type = parts[1] if len(parts) > 1 else None
try:
with open(os.path.expanduser(filename), 'rb') as f:
contents = f.read()
f = open(os.path.expanduser(filename), 'rb')
except IOError as e:
raise ParseError('"%s": %s' % (arg.orig, e))
return (
os.path.basename(filename),
BytesIO(contents),
f,
mime_type or get_content_type(filename),
)