Comment 7 for bug 1363348

Revision history for this message
Jason Hobbs (jason-hobbs) wrote : Re: Image uploads from the cli fail when file size is greater than 47406

Django's multipartparser splits incoming data into chunks to process it. On my system, these chunk sizes are 64kb at largest, but are always a multiple of 4 when decoding base64 data, since base64 encoded data must be split at 4 byte boundaries. django is taking the len() of the string of data and making sure that's a multiple of 4, and passing the string to b64decode to decode.

I believe the problem is the data apiclient uploads includes CRLF characters. Django counts those characters as a part of the string when considering the length of a chunk of base64 data, but the CRLF characters aren't significant in base64, so the resulting pure base64 data, with whitespace stripped, isn't necessarily aligned to a 4 byte boundary.