Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Fix improper use of Requests for file upload #35

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions hellosign_sdk/utils/hsformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#

import os

class HSFormat(object):
''' Authentication object using HelloSign's access token '''
Expand All @@ -42,10 +43,13 @@ def format_file_params(files):
'''
Utility method for formatting file parameters for transmission
'''
files_payload = {}
files_payload = []
if files:
for idx, filename in enumerate(files):
files_payload["file[" + str(idx) + "]"] = open(filename, 'rb')
files_payload.append((
'file[%s]' % idx,
(os.path.basename(filename), open(filename, 'rb'))
))
return files_payload

@staticmethod
Expand Down Expand Up @@ -129,4 +133,4 @@ def format_custom_fields(list_of_custom_fields):
@staticmethod
def strip_none_values(dictionary):
if dictionary:
return dict((key, value) for (key, value) in dictionary.items() if value)
return dict((key, value) for (key, value) in dictionary.items() if value)