Skip to content

File class

esmerald.datastructures.file.File

Bases: ResponseContainer[FileResponse]

path instance-attribute

path

The path to the file to download.

filename instance-attribute

filename

The name of the file to be added to the Content-Disposition attachment.

to_response

to_response(headers, media_type, status_code, app)
PARAMETER DESCRIPTION
headers

TYPE: Dict[str, Any]

media_type

TYPE: Union[MediaType, str]

status_code

TYPE: int

app

TYPE: Type[Esmerald]

Source code in esmerald/datastructures/file.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def to_response(
    self,
    headers: Dict[str, Any],
    media_type: Union["MediaType", str],
    status_code: int,
    app: Type["Esmerald"],
) -> FileResponse:
    return FileResponse(
        background=self.background,
        filename=self.filename,
        headers=headers,
        media_type=media_type,
        path=self.path,
        stat_result=self.stat_result,
        status_code=status_code,
    )