Skip to content Skip to sidebar Skip to footer

Python Extracting Binary From A Post Request Using Web.py

I am developing an API that allows outside clients to send a binary file which will be processed. my web.data() is a string and the function I am calling requires a binary. How do

Solution 1:

Even if it is a binary file, reading raw post data would get you a encoded string. You would need to decode to convert to binary data. You can write to a file as follows:

 written = open('binary.file', 'wb')
 for chunk in rawdata.chunks():
        written.write(chunk)
 written.close()

Post a Comment for "Python Extracting Binary From A Post Request Using Web.py"