class_docstr: Base data class representing a binary object in the Haystack API.
docstr: Create a ByteStream encoding a string.
  
  :param text: The string to encode
  :param encoding: The encoding used to convert the string into bytes
docstr_tok: ["Create","a","ByteStream","encoding","a","string",".",":","param","text",":","The","string","to","encode",":","param","encoding",":","The","encoding","used","to","convert","the","string","into","bytes"]
code: def from_string(
      cls,
      text: str,
      encoding: str = "utf-8",
      mime_type: Optional[str] = None,
  ) -> "ByteStream":
      """
      Create a ByteStream encoding a string.
  
      :param text: The string to encode
      :param encoding: The encoding used to convert the string into bytes
      """
      return cls(data=text.encode(encoding), mime_type=mime_type)
  
imports: from dataclasses import dataclass, field
  from pathlib import Path
  from typing import Optional, Dict, Any
label_desc: Use image node_id 3 for calling the ByteStream obj's underlying member method code with example usage: obj.from_string(cls, text, encoding, mime_type) and returns: cls