def __upload_file_to_slack(self, block: FileBlock, max_log_file_limit_kb: int) -> Optional[str]:
        """Upload a file to Slack and return a permalink to it."""
        truncated_content = block.truncate_content(max_file_size_bytes=max_log_file_limit_kb * 1000)
        filename = block.filename

        try:
            with tempfile.NamedTemporaryFile() as f:
                logging.debug("Trying NamedTemporaryFile for Slack upload")
                return self._upload_temp_file(f, f.name, truncated_content, filename)
        except Exception as e:
            logging.debug(f"NamedTemporaryFile failed: {e}")
        try:
            SPOOLED_FILE_SIZE = 10 * 1000 * 1000  # 10MB to protect against OOM
            with tempfile.SpooledTemporaryFile(max_size=SPOOLED_FILE_SIZE) as f:
                logging.debug("Trying SpooledTemporaryFile for Slack upload")
                return self._upload_temp_file(f, f, truncated_content, filename)
        except Exception as e2:
            logging.exception(f"SpooledTemporaryFile also failed: {e2}")
            return None
Upload a file to Slack and return a permalink to it.
src/robusta/integrations/slack/sender.py