def encode_multipart_formdata(self, fields, filename, verbose=False):
BOUNDARY = '<STR_LIT>'<EOL>CRLF = '<STR_LIT:\r\n>'<EOL>content_type = '<STR_LIT>' % BOUNDARY<EOL>if verbose is True:<EOL><INDENT>print(('<STR_LIT>' + filename + '<STR_LIT>'))<EOL><DEDENT>fin = open(filename, '<STR_LIT:rb>')<EOL>fout = open(filename + '<STR_LIT>', '<STR_LIT:wb>')<EOL>fout.write(bytearray('<STR_LIT>' + BOUNDARY + CRLF, '<STR_LIT:utf-8>'))<EOL>fout.write(bytearray('<STR_LIT>'<EOL>'<STR_LIT>' +<EOL>filename + '<STR_LIT:">' + CRLF, "<STR_LIT:utf-8>"))<EOL>fout.write(bytearray('<STR_LIT>' + CRLF,<EOL>'<STR_LIT:utf-8>'))<EOL>fout.write(bytearray(CRLF, '<STR_LIT:utf-8>'))<EOL>shutil.copyfileobj(fin, fout)<EOL>fout.write(bytearray(CRLF, '<STR_LIT:utf-8>'))<EOL>fout.write(bytearray('<STR_LIT>' + BOUNDARY + '<STR_LIT>' + CRLF, '<STR_LIT:utf-8>'))<EOL>fout.write(bytearray(CRLF, '<STR_LIT:utf-8>'))<EOL>fout.close()<EOL>fin.close()<EOL>return content_type<EOL>
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data
to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance