class_docstr: Storage that stores files in amazon s3
      
class_docstr_tok: ["Storage","that","stores","files","in","amazon","s3"]
code: def put(self, local_name, base_dir, compression_level=9):
      # NOTE: This `make_archive` function is implemente poorly and will create an empty archive file even if
      # the file/dir to be archived doesn't exist or for some other reason can't be archived
      remote_name = local_name
      remote_zipped_name = f"{remote_name}.tar.gz"
  
      dir_path = Path(base_dir) / remote_name
      dir_size = sum(
          f.stat().st_size for f in dir_path.glob("**/*") if f.is_file()
      )
      if (dir_size * 2) < psutil.virtual_memory().available:
          old_cwd = os.getcwd()
          fh = io.BytesIO()
          with self._thread_lock:
              os.chdir(base_dir)
              with tarfile.open(
                  fileobj=fh,
                  mode="w:gz",
                  compresslevel=compression_level,
              ) as tar:
                  for path in dir_path.iterdir():
                      if (
                          path.is_file()
                          and path.name in SERVICE_FILES_NAMES
                      ):
                          continue
                      tar.add(path.relative_to(base_dir))
              os.chdir(old_cwd)
          fh.seek(0)
  
          self.s3.upload_fileobj(fh, self.bucket, remote_zipped_name)
      else:
          shutil.make_archive(
              os.path.join(base_dir, remote_name),
              "gztar",
              root_dir=base_dir,
              base_dir=local_name,
          )
  
          self.s3.upload_file(
              os.path.join(base_dir, remote_zipped_name),
              self.bucket,
              remote_zipped_name,
          )
          os.remove(os.path.join(base_dir, remote_zipped_name))
  
      last_modified = self._get_remote_last_modified(remote_zipped_name)
      self._save_local_last_modified(
          base_dir, local_name, last_modified
      )
  
imports: import os
  import io
  import shutil
  import tarfile
  import hashlib
  from pathlib import Path
  from abc import ABC, abstractmethod
  from typing import Union, Optional
  from dataclasses import dataclass
  from datetime import datetime
  import threading
  import psutil
  from checksumdir import dirhash
  from mindsdb.utilities.config import Config
  from mindsdb.utilities.context import context
  import mindsdb.utilities.profiler
  from mindsdb.utilities import log
label_desc: Use image node_id 7 for calling the S3FSStore obj's underlying member method code with example usage: obj.put(local_name, base_dir, compression_level) without return types