mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
feat(file-download): add inline or attachment option for file previews
- Introduced 'as_attachment' argument to specify download mode. - Enables flexible file display as inline or attachment. - Enhances user control over file preview behavior.
This commit is contained in:
parent
6d818418a3
commit
9797935c73
|
@ -16,6 +16,7 @@ class ToolFilePreviewApi(Resource):
|
|||
parser.add_argument("timestamp", type=str, required=True, location="args")
|
||||
parser.add_argument("nonce", type=str, required=True, location="args")
|
||||
parser.add_argument("sign", type=str, required=True, location="args")
|
||||
parser.add_argument("as_attachment", type=bool, defaule=False, required=False, location="args")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -43,10 +44,11 @@ class ToolFilePreviewApi(Resource):
|
|||
direct_passthrough=True,
|
||||
headers={
|
||||
"Content-Length": str(tool_file.size),
|
||||
"Content-Disposition": f"attachment; filename={tool_file.name}",
|
||||
},
|
||||
)
|
||||
if tool_file.mimetype.startswith("image"):
|
||||
if args["as_attachment"]:
|
||||
response.headers["Content-Disposition"] = f"attachment; filename={tool_file.name}"
|
||||
else:
|
||||
response.headers["Content-Disposition"] = f"inline; filename={tool_file.name}"
|
||||
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue
Block a user