My Python code opens up a few WAV files and puts them into a base64 encoded string then sends to a server via HTTP. Every 50 transmissions or so some encWAV string data loses its "=" padding. I end up with data in fullBase64Data and some of the segments have the correct padding and others do not. I can't figure out a rhyme or reason to this. What is causing this and how can I fix the issue?
f = open(requestID + '/' + str(i) + '.wav', 'rb')
encWAV = b64encode(f.read())
f.close()
fullBase64Data = fullBase64Data + "::SPLITWAV::" + encWAV.decode('ascii');
url = 'http://REMOVED.com/queue/removed.php';
post_fields = {'RequestID': requestID, 'AudioData': fullBase64Data,'AgentName': agentName};
request = Request(url, urllib.urlencode(post_fields).encode());