o
    ßñh  ã                   @  sd   d dl mZ d dlmZ d dlmZ d dlmZ G dd„ deƒZG dd„ de	ƒZ
G d	d
„ d
eƒZdS )é    )Úannotations)Úabstractmethod)ÚEnum)ÚProtocolc                   @  s   e Zd ZdZdZdS )ÚMediaFileKindÚmediaÚdownloadableN)Ú__name__Ú
__module__Ú__qualname__ÚMEDIAÚDOWNLOADABLE© r   r   úX/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/runtime/media_file_storage.pyr      s    r   c                   @  s   e Zd ZdZdS )ÚMediaFileStorageErroraf  Exception class for errors raised by MediaFileStorage.

    When running in "development mode", the full text of these errors
    is displayed in the frontend, so errors should be human-readable
    (and actionable).

    When running in "release mode", errors are redacted on the
    frontend; we instead show a generic "Something went wrong!" message.
    N)r	   r
   r   Ú__doc__r   r   r   r   r      s    r   c                   @  s:   e Zd Ze	dddd„ƒZeddd„ƒZeddd„ƒZdS )ÚMediaFileStorageNÚpath_or_dataústr | bytesÚmimetypeÚstrÚkindr   Úfilenameú
str | NoneÚreturnc                 C  ó   t ‚)a  Load the given file path or bytes into the manager and return
        an ID that uniquely identifies it.

        It's an error to pass a URL to this function. (Media stored at
        external URLs can be served directly to the Streamlit frontend;
        there's no need to store this data in MediaFileStorage.)

        Parameters
        ----------
        path_or_data
            A path to a file, or the file's raw data as bytes.

        mimetype
            The media's mimetype. Used to set the Content-Type header when
            serving the media over HTTP.

        kind
            The kind of file this is: either MEDIA, or DOWNLOADABLE.

        filename : str or None
            Optional filename. Used to set the filename in the response header.

        Returns
        -------
        str
            The unique ID of the media file.

        Raises
        ------
        MediaFileStorageError
            Raised if the media can't be loaded (for example, if a file
            path is invalid).

        ©ÚNotImplementedError)Úselfr   r   r   r   r   r   r   Úload_and_get_id+   s   *z MediaFileStorage.load_and_get_idÚfile_idc                 C  r   )aá  Return a URL for a file in the manager.

        Parameters
        ----------
        file_id
            The file's ID, returned from load_media_and_get_id().

        Returns
        -------
        str
            A URL that the frontend can load the file from. Because this
            URL may expire, it should not be cached!

        Raises
        ------
        MediaFileStorageError
            Raised if the manager doesn't contain an object with the given ID.

        r   ©r   r    r   r   r   Úget_urlW   s   zMediaFileStorage.get_urlÚNonec                 C  r   )a  Delete a file from the manager.

        This should be called when a given file is no longer referenced
        by any connected client, so that the MediaFileStorage can free its
        resources.

        Calling `delete_file` on a file_id that doesn't exist is allowed,
        and is a no-op. (This means that multiple `delete_file` calls with
        the same file_id is not an error.)

        Note: implementations can choose to ignore `delete_file` calls -
        this function is a *suggestion*, not a *command*. Callers should
        not rely on file deletion happening immediately (or at all).

        Parameters
        ----------
        file_id
            The file's ID, returned from load_media_and_get_id().

        Returns
        -------
        None

        Raises
        ------
        MediaFileStorageError
            Raised if file deletion fails for any reason. Note that these
            failures will generally not be shown on the frontend (file
            deletion usually occurs on session disconnect).

        r   r!   r   r   r   Údelete_filen   s   !zMediaFileStorage.delete_file)N)
r   r   r   r   r   r   r   r   r   r   )r    r   r   r   )r    r   r   r#   )r	   r
   r   r   r   r"   r$   r   r   r   r   r   *   s    û+r   N)Ú
__future__r   Úabcr   Úenumr   Útypingr   r   Ú	Exceptionr   r   r   r   r   r   Ú<module>   s   