Skip to main content

ShareFile

Represents a file to share, either from disk or in-memory bytes.

Properties

  • data - Raw bytes of the file to share.
  • mime_type - MIME type of the file.
  • name - Optional name of the file.
  • path - Filesystem path to the file to share.

Methods

Properties

dataclass-attributeinstance-attribute

data: Optional[bytes] = None

Raw bytes of the file to share.

mime_typeclass-attributeinstance-attribute

mime_type: Optional[str] = None

MIME type of the file.

nameclass-attributeinstance-attribute

name: Optional[str] = None

Optional name of the file.

pathclass-attributeinstance-attribute

path: Optional[str] = None

Filesystem path to the file to share.

Methods

from_bytesstaticmethod

from_bytes(data: bytes, mime_type: Optional[str] = None, name: Optional[str] = None)

Create ShareFile from raw bytes.

Parameters:

  • data (bytes) - Raw bytes of the file.
  • mime_type (Optional[str], default: None) - Optional MIME type of the file.
  • name (Optional[str], default: None) - Optional name of the file.

from_pathstaticmethod

from_path(path: str, name: Optional[str] = None)

Create ShareFile from a filesystem path.

Parameters:

  • path (str) - Filesystem path to the file.
  • name (Optional[str], default: None) - Optional name of the file.