def __upload_file_to_rocketchat(self, block: FileBlock, tmid: str):

        """Upload a file to rocketchat and return a link to it"""
        with tempfile.TemporaryDirectory() as temp_dir:
            f = open(os.path.join(temp_dir, block.filename), 'wb')
            f.write(block.contents)
            f.flush()

            try:
                result = self.rocketchat_client.rooms_upload(rid=self.room_id, file=f.name, tmid=tmid)

                result.raise_for_status()

            except Exception as e:
                logging.error(
                    f"error uploading file to rocketchat\ne={e}\nuser_id: {self.user_id}\nserver_url: {self.server_url}\nf.name: {f.name}"
                )
Upload a file to rocketchat and return a link to it
src/robusta/integrations/rocketchat/sender.py