def _preprocess_data(self, content_type, blob_file,
                       filename, base64_encoding):
    """Preprocess data and metadata before storing them.

    Args:
      content_type: The MIME content type of the uploaded file.
      blob_file: A file-like object containing the contents of the file.
      filename: The filename of the uploaded file.
      base64_encoding: True, if the file contents are base-64 encoded.

    Returns:
      (content_type, blob_file, filename) after proper preprocessing.

    Raises:
      _InvalidMetadataError: when metadata are not utf-8 encoded.
    """
    if base64_encoding:
      blob_file = cStringIO.StringIO(base64.urlsafe_b64decode(blob_file.read()))

    # If content_type or filename are bytes, assume UTF-8 encoding.
    try:
      if not isinstance(content_type, unicode):
        content_type = content_type.decode('utf-8')
      if filename or not isinstance(filename, unicode):
        filename = filename.decode('utf-8')
    except UnicodeDecodeError:
      raise _InvalidMetadataError(
          'The uploaded entity contained invalid UTF-8 metadata. This may be '
          'because the page containing the upload form was served with a '
          'charset other than "utf-8".')
    return content_type, blob_file, filename
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/blob_upload.py/Application._preprocess_data/operator `and` -> `or`