Script Development / Return File DFF.RESP_FILE
When the returned content is a "file on disk," you can use DFF.RESP_FILE(...)
for detailed control.
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
file_path |
str | Required | Specifies the path to the returned file (relative to the resource file directory). |
status_code |
int | 200 |
Same as the parameter with the same name in DFF.RESP(...) . |
headers |
dict | None |
Same as the parameter with the same name in DFF.RESP(...) . |
allow_304 |
bool | False |
Same as the parameter with the same name in DFF.RESP(...) . |
auto_delete |
bool | False |
When set to True , the file will be automatically deleted from the disk after download. |
download |
bool / str | True |
Downloads the file by default and saves it with the same name as the original file. When set to False , instructs the browser to open the file directly if possible.When set to a string, uses the specified value as the downloaded filename. |
DFF.RESP_FILE(...) will automatically populate the HTTP Content-Type header based on the file extension, defaulting to file_path
. If a download string is specified, the download value will be used as the filename.
The 'resource file directory' refers to the /data/resources folder within the container, which will be mounted to the host machine's disk after normal deployment to achieve persistent storage.
Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|