Encode form (name, value) and (name, filename, type) elements into
multi-part/form-data. We don't actually need to know what we are
uploading here, so just claim it's all text/plain.
Definition at line 40 of file visDQMUpload.py.
References filetype(), and str.
Referenced by marshall().
42 Encode form (name, value) and (name, filename, type) elements into 43 multi-part/form-data. We don't actually need to know what we are 44 uploading here, so just claim it's all text/plain. 46 boundary =
'----------=_DQM_FILE_BOUNDARY_=-----------' 47 (body, crlf) = (
'',
'\r\n')
48 for (key, value)
in args.items():
50 body +=
'--' + boundary + crlf
51 body += (
'Content-Disposition: form-data; name="%s"' % key) + crlf
52 body += crlf + payload + crlf
53 for (key, filename)
in files.items():
54 body +=
'--' + boundary + crlf
55 body += (
'Content-Disposition: form-data; name="%s"; filename="%s"' 56 % (key, os.path.basename(filename))) + crlf
57 body += (
'Content-Type: %s' %
filetype(filename)) + crlf
58 body += (
'Content-Length: %d' % os.stat(filename)[ST_SIZE]) + crlf
59 body += crlf + open(filename,
"r").read() + crlf 60 body += '--' + boundary +
'--' + crlf + crlf
61 return (
'multipart/form-data; boundary=' + boundary, body)