FN-7073: serve file previews inline
File viewer previews now request inline-safe responses while downloads remain attachments. - Add an inline preview query option to file download URL helpers and preview consumers. - Serve known media and PDF preview extensions with real MIME types, inline disposition, nosniff, and sandbox CSP headers. - Keep explicit downloads and unknown file types on attachment/octet-stream behavior. - Cover preview and download header behavior with dashboard route and component tests. Files changed: .changeset/fn-7073-file-viewer-inline-preview.md | 7 + docs/dashboard-guide.md | 2 +- packages/dashboard/app/api/legacy.ts | 9 +- .../dashboard/app/components/DockFilesView.tsx | 2 +- .../dashboard/app/components/FileBrowserModal.tsx | 2 +- .../components/__tests__/DockFilesView.test.tsx | 14 +- .../components/__tests__/FileBrowserModal.test.tsx | 12 +- .../register-file-workspace-routes.test.ts | 141 +++++++++++++++++++++ .../src/routes/register-file-workspace-routes.ts | 111 +++++++++++----- 9 files changed, 260 insertions(+), 40 deletions(-) Fusion-Task-Id: FN-7073 Fusion-Task-Lineage: 922b4aa4-ac6d-4a59-b94f-bab4eeb65530
This commit is contained in:
@@ -3511,11 +3511,18 @@ export function renameFile(workspace: string, filePath: string, newName: string,
|
||||
}
|
||||
|
||||
/** Get the download URL for a single file in a workspace. */
|
||||
export function downloadFileUrl(workspace: string, filePath: string, projectId?: string): string {
|
||||
export function downloadFileUrl(workspace: string, filePath: string, projectId?: string, options?: { inline?: boolean }): string {
|
||||
const query = new URLSearchParams({ workspace });
|
||||
if (projectId) {
|
||||
query.set("projectId", projectId);
|
||||
}
|
||||
/**
|
||||
* FNXC:FileBrowser 2026-06-26-00:00:
|
||||
* Browser-native preview consumers request `inline=1` so the shared download route serves renderable MIME types with inline disposition. The explicit Download action intentionally omits this option to preserve attachment downloads.
|
||||
*/
|
||||
if (options?.inline === true) {
|
||||
query.set("inline", "1");
|
||||
}
|
||||
return `/api/files/${encodeURIComponent(filePath)}/download?${query.toString()}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user