code: def marshall_file(
      coordinates: str,
      data: DownloadButtonDataType,
      proto_download_button: DownloadButtonProto,
      mimetype: Optional[str],
      file_name: Optional[str] = None,
  ) -> None:
      data_as_bytes: bytes
      if isinstance(data, str):
          data_as_bytes = data.encode()
          mimetype = mimetype or "text/plain"
      elif isinstance(data, io.TextIOWrapper):
          string_data = data.read()
          data_as_bytes = string_data.encode()
          mimetype = mimetype or "text/plain"
      # Assume bytes; try methods until we run out.
      elif isinstance(data, bytes):
          data_as_bytes = data
          mimetype = mimetype or "application/octet-stream"
      elif isinstance(data, io.BytesIO):
          data.seek(0)
          data_as_bytes = data.getvalue()
          mimetype = mimetype or "application/octet-stream"
      elif isinstance(data, io.BufferedReader):
          data.seek(0)
          data_as_bytes = data.read()
          mimetype = mimetype or "application/octet-stream"
      elif isinstance(data, io.RawIOBase):
          data.seek(0)
          data_as_bytes = data.read() or b""
          mimetype = mimetype or "application/octet-stream"
      else:
          raise RuntimeError(
              "Invalid binary data format: %s" % type(data)
          )
  
      if runtime.exists():
          file_url = runtime.get_instance().media_file_mgr.add(
              data_as_bytes,
              mimetype,
              coordinates,
              file_name=file_name,
              is_for_static_download=True,
          )
      else:
          # When running in "raw mode", we can't access the MediaFileManager.
          file_url = ""
  
      proto_download_button.url = file_url
  
imports: import io
  from dataclasses import dataclass
  from textwrap import dedent
  from typing import TYPE_CHECKING, BinaryIO, Optional, TextIO, Union, cast
  from typing_extensions import Final, Literal
  from streamlit import runtime
  from streamlit.elements.form import current_form_id, is_in_form
  from streamlit.elements.utils import check_callback_rules, check_session_state_rules
  from streamlit.errors import StreamlitAPIException
  from streamlit.proto.Button_pb2 import Button
  from streamlit.proto.DownloadButton_pb2 import DownloadButton
  from streamlit.proto.LinkButton_pb2 import LinkButton
  from streamlit.runtime.metrics_util import gather_metrics
  from streamlit.runtime.scriptrunner import ScriptRunContext, get_script_run_ctx
  from streamlit.runtime.state import WidgetArgs, WidgetCallback, WidgetKwargs, register_widget
  from streamlit.runtime.state.common import compute_widget_id
  from streamlit.type_util import Key, to_key
label_desc: Use image node_id 1 for calling a global function with example usage: marshall_file(coordinates, data, proto_download_button, mimetype, file_name) without return types