fix: PDFs im Preview-iframe statt neuem Tab

Download-Endpoint unterstuetzt jetzt ?inline=1, wodurch
Content-Disposition auf inline statt attachment gesetzt wird.
PDF- und Bild-Preview nutzen diesen Parameter, damit der
Browser das PDF im Preview-Iframe rendert statt einen Download
auszuloesen. Normale Download-Buttons bleiben unveraendert.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Hacker
2026-04-12 09:55:40 +02:00
parent 50385faa02
commit 6aad986d78
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -283,8 +283,11 @@ def download_file(file_id):
if not filepath.exists(): if not filepath.exists():
return jsonify({'error': 'Datei auf Datentraeger nicht gefunden'}), 404 return jsonify({'error': 'Datei auf Datentraeger nicht gefunden'}), 404
return send_file(str(filepath), mimetype=f.mime_type, as_attachment=True, # inline=1 renders the file in-browser (used by PDF/image previews).
download_name=f.name) # Default is attachment so normal download buttons still save to disk.
inline = request.args.get('inline', '0') == '1'
return send_file(str(filepath), mimetype=f.mime_type,
as_attachment=not inline, download_name=f.name)
def _download_folder_as_zip(folder): def _download_folder_as_zip(folder):
+1 -1
View File
@@ -157,7 +157,7 @@ async function loadPreview() {
previewType.value = data.type previewType.value = data.type
if (data.type === 'pdf' || data.type === 'image') { if (data.type === 'pdf' || data.type === 'image') {
previewUrl.value = getTokenUrl(`/api/files/${fileId}/download`) previewUrl.value = getTokenUrl(`/api/files/${fileId}/download?inline=1`)
canEdit.value = false canEdit.value = false
} else if (data.type === 'html') { } else if (data.type === 'html') {
htmlContent.value = data.content htmlContent.value = data.content