def METHOD_NAME(self, fieldname, filename, mimetype=None):
    """Add a file to be uploaded."""
    file_handle = None
    try:
        file_handle = codecs.open(filename, "rb")
        body = file_handle.read()
    finally:
        if file_handle:
            file_handle.close()
    basename = os.path.basename(filename)
    if mimetype is None:
        mimetype = mimetypes.guess_type(basename)[0] or 'application/octet-stream'
    self.files.append((fieldname, basename, mimetype, body))