Skip to content

ShareFile

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

Properties

Methods

  • from_bytes

    Create ShareFile from raw bytes.

  • from_path

    Create ShareFile from a filesystem path.

Properties#

data: Optional[bytes] = None class-attribute instance-attribute #

Raw bytes of the file to share.

mime_type: Optional[str] = None class-attribute instance-attribute #

MIME type of the file.

name: Optional[str] = None class-attribute instance-attribute #

Optional name of the file.

path: Optional[str] = None class-attribute instance-attribute #

Filesystem path to the file to share.

Methods#

from_bytes(data: bytes, *, mime_type: Optional[str] = None, name: Optional[str] = None) -> ShareFile staticmethod #

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_path(path: str, *, name: Optional[str] = None) -> ShareFile staticmethod #

Create ShareFile from a filesystem path.

Parameters:

  • path (str) –

    Filesystem path to the file.

  • name (Optional[str], default: None ) –

    Optional name of the file.