Post

1 follower Follow
0
Avatar

Uploading DOCX file with Python API

Hello,

I'm using pypodio in a python script that I'm running locally, Windows 8 with Python 2.7. I'm able to authenticate and create new items, and was able to successfully upload a 1.3MB text file.

When I try to upload a DOCX file created by MS Word 2013 however, my script just hangs at the command line. I can replicate with DOCX files, but other files upload fine, regardless of size. DOCX files just hang when uploading - no feedback or errors.

Any idea why this might be?

Podio = api.OAuthClient(client_id,client_secret,username,password)

filename = btor['filename']
filedata = open('get-pip.txt','r')
#filedata = open('get-pip.txt','r')
upload = Podio.Files.create(filename,filedata)

print upload

Thanks,
Joe

Joe Contini

Please sign in to leave a comment.

1 comment

0
Avatar

OK, after about 4 hours of troubleshooting, I finally figures out that I need to open the file as binary with 'rb' instead of 'r'.

filedata = open(btor['filepath'],'rb')

Joe Contini 0 votes