code: def get_file_info(obj, fieldname, default=None):
      
  
      # extract the file field from the object if omitted
      field = get_field(obj, fieldname)
  
      # get the value with the fieldmanager
      fm = IFieldManager(field)
  
      # return None if we have no file data
      if fm.get_size(obj) == 0:
          return None
  
      out = {
          "content_type": fm.get_content_type(obj),
          "filename": fm.get_filename(obj),
          "download": fm.get_download_url(obj),
      }
  
      # only return file data only if requested (?filedata=yes)
      if req.get_filedata(False):
          data = fm.get_data(obj)
          out["data"] = data.encode("base64")
  
      return out
docs: Extract file data from a file field
  
      :param obj: Content object
      :type obj: ATContentType/DexterityContentType
      :param fieldname: Schema name of the field
      :type fieldname: str/unicode
      :returns: File data mapping
      :rtype: dict