I am trying to send multiple files in a post request. Following is the code I use.
orig_src = "./orig_src/"
url = "http://"+server+":"+port+"/my_service"
files = []
for root, dirs, files in os.walk(orig_src):
for fileName in files:
if len(files) > 0:
relDir = os.path.relpath(root, orig_src)
relFile = os.path.join(relDir, fileName)
files.append(('srcFile', (fileName, open(orig_src+relFile, 'rb'))))
response = requests.post(url, files = files)
I get the following error when I try to do this:
File "/usr/lib/python2.7/posixpath.py", line 66, in join
if b.startswith('/'):
AttributeError: 'tuple' object has no attribute 'startswith'
Any idea where the error might be? earlier I created a curl request using -F option and ran it using os.system command. That was running fine. But I am not able to send the post request now. where am i going wrong?