diff options
| author | diogo464 <[email protected]> | 2025-08-13 11:33:51 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-13 11:33:51 +0100 |
| commit | ca703fd5de303d2101fe2b2a5c0e3037b7507156 (patch) | |
| tree | 7078378ea380b1cfdf502aa62f2e1ada5708ccac /frontend/components | |
| parent | 74069a896a3b831a19baefc0d9487060b34760b3 (diff) | |
Implement path-based downloads with blob redirect system
- Add fctdrive stat command to get blob IDs from paths
- Add Drive_stat function to drive_server.ts for backend integration
- Create /download/[...path] endpoint that redirects to /blob/{blobId}
- Update UI file links to use /download/ paths instead of direct blob links
- Update permalinks to use immutable /blob/{blobId} URLs
- Fix host preservation in redirects for remote access
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/drive/DriveDirectoryClient.tsx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/frontend/components/drive/DriveDirectoryClient.tsx b/frontend/components/drive/DriveDirectoryClient.tsx index 6089ec2..c405341 100644 --- a/frontend/components/drive/DriveDirectoryClient.tsx +++ b/frontend/components/drive/DriveDirectoryClient.tsx | |||
| @@ -125,11 +125,21 @@ export function DriveDirectoryClient({ path, files, breadcrumbs }: DriveDirector | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | const copyPermalink = (item: DriveLsEntry) => { | 127 | const copyPermalink = (item: DriveLsEntry) => { |
| 128 | const permalink = `${window.location.origin}/drive/file/${item.path}` | 128 | if (!item.blob) { |
| 129 | toast({ | ||
| 130 | title: "Cannot copy permalink", | ||
| 131 | description: "This item does not have a blob ID", | ||
| 132 | variant: "destructive" | ||
| 133 | }) | ||
| 134 | return | ||
| 135 | } | ||
| 136 | |||
| 137 | const filename = item.path.split('/').pop() || 'download' | ||
| 138 | const permalink = `${window.location.origin}/blob/${item.blob}?filename=${encodeURIComponent(filename)}` | ||
| 129 | navigator.clipboard.writeText(permalink).then(() => { | 139 | navigator.clipboard.writeText(permalink).then(() => { |
| 130 | toast({ | 140 | toast({ |
| 131 | title: "Link copied!", | 141 | title: "Permalink copied!", |
| 132 | description: "Permalink has been copied to clipboard", | 142 | description: "Permanent blob link has been copied to clipboard", |
| 133 | }) | 143 | }) |
| 134 | }) | 144 | }) |
| 135 | } | 145 | } |
| @@ -531,7 +541,7 @@ export function DriveDirectoryClient({ path, files, breadcrumbs }: DriveDirector | |||
| 531 | <div className="min-w-0 max-w-[60vw]"> | 541 | <div className="min-w-0 max-w-[60vw]"> |
| 532 | {file.blob ? ( | 542 | {file.blob ? ( |
| 533 | <a | 543 | <a |
| 534 | href={`/blob/${file.blob}?filename=${encodeURIComponent(fileName)}`} | 544 | href={`/download${file.path}`} |
| 535 | className="text-blue-600 hover:text-blue-800 hover:underline cursor-pointer block truncate" | 545 | className="text-blue-600 hover:text-blue-800 hover:underline cursor-pointer block truncate" |
| 536 | target="_blank" | 546 | target="_blank" |
| 537 | rel="noopener noreferrer" | 547 | rel="noopener noreferrer" |
