Skip to content

Commit 776ce33

Browse files
author
Laurynas Butkus
committed
Handle multiple files upload
1 parent 996579f commit 776ce33

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

convertapi/task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def __normalize_params(self):
3434
if k == 'File':
3535
params[k] = file_param.build(v)
3636
elif k == 'Files':
37-
params[k] = map(file_param.build, v)
37+
for idx, val in enumerate(v):
38+
key = '%s[%i]' % (k, idx)
39+
params[key] = file_param.build(val)
3840
else:
3941
params[k] = v
4042

tests/test_convertapi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ def test_upload_io(self):
3131
upload_io = convertapi.UploadIO(bytes_io, 'test.txt')
3232
result = convertapi.convert('pdf', { 'File': upload_io })
3333
assert result.conversion_cost > 0
34+
35+
def test_zip_files(self):
36+
files = ['examples/files/test.docx', 'examples/files/test.docx']
37+
result = convertapi.convert('zip', { 'Files': files })
38+
print result.file.url
39+
assert result.conversion_cost > 0

0 commit comments

Comments
 (0)