docstr: Add a file to the manager and return its ID.
docstr_tok: ["Add","a","file","to","the","manager","and","return","its","ID","."]
code: def load_and_get_id(
      self,
      path_or_data: Union[str, bytes],
      mimetype: str,
      kind: MediaFileKind,
      filename: Optional[str] = None,
  ) -> str:
      """Add a file to the manager and return its ID."""
      file_data: bytes
      if isinstance(path_or_data, str):
          file_data = self._read_file(path_or_data)
      else:
          file_data = path_or_data
  
      # Because our file_ids are stable, if we already have a file with the
      # given ID, we don't need to create a new one.
      file_id = _calculate_file_id(file_data, mimetype, filename)
      if file_id not in self._files_by_id:
          LOGGER.debug("Adding media file %s", file_id)
          media_file = MemoryFile(
              content=file_data,
              mimetype=mimetype,
              kind=kind,
              filename=filename,
          )
          self._files_by_id[file_id] = media_file
  
      return file_id
  
imports: import contextlib
  import hashlib
  import mimetypes
  import os.path
  from typing import Dict, List, NamedTuple, Optional, Union
  from typing_extensions import Final
  from streamlit.logger import get_logger
  from streamlit.runtime.media_file_storage import MediaFileKind, MediaFileStorage, MediaFileStorageError
  from streamlit.runtime.stats import CacheStat, CacheStatsProvider, group_stats
  from streamlit.util import HASHLIB_KWARGS
label_desc: Use image node_id 2 for calling the MemoryMediaFileStorage obj's underlying member method code with example usage: obj.load_and_get_id(path_or_data, mimetype, kind, filename) and returns: file_id