Skip to content

Commit 44bbfb1

Browse files
fix: BIDS file downloads route through data.nemar.org for filename preservation
Tree links previously pointed at the manifest's presigned S3 URL (f.url), which sends users straight to the content-addressed object — browsers then download with the SHA-named filename ('SHA256E-s197576448--c70cae6e4a043e2124d7e5ee94422d02.bdf') rather than the BIDS-shaped name they expect ('sub-01_task-typing_emg.bdf'). Fix: route every file link through data.nemar.org/<id>/<v>/<bids-path> so the Worker's redirect is in the chain. Also adds the HTML 'download' attribute as a hint with the basename. This alone won't fix the SHA-naming today — the Worker still 302s to the same presigned URL without setting response-content-disposition. But once nemarOrg/nemar-cli#513 ships (filing now), the Worker will add response-content-disposition=attachment; filename="<bids-basename>" to the presign and filenames will start being correct. This commit puts the frontend in position to benefit immediately when that lands.
1 parent 36e9c6c commit 44bbfb1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎src/components/BidsDirChildren.astro‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ function countFilesDeep(n: TreeNode): number {
4949
class="tree__row tree__row--file"
5050
style={`padding-inline-start: calc(var(--space-5) + ${depth} * var(--space-5) + 16px)`}
5151
>
52-
<a class="tree__name" href={f.url} rel="external" title={`Download ${f.path}`}>
52+
<a
53+
class="tree__name"
54+
href={`${basePath}/${encodeURI(f.path)}`}
55+
rel="external"
56+
download={f.path.split("/").pop()}
57+
title={`Download ${f.path}`}
58+
>
5359
{f.path.split("/").pop()}
5460
</a>
5561
<span class="tree__size">{formatBytes(f.size)}</span>

‎src/components/BidsTree.astro‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ function countFilesDeep(n: TreeNode): number {
3535
return (
3636
<li class="tree__row">
3737
<span class="tree__icon" aria-hidden="true">▪</span>
38-
<a class="tree__name" href={f.url ?? `${basePath}/${f.path}`} rel="external" title={`Download ${f.path}`}>
38+
<a
39+
class="tree__name"
40+
href={`${basePath}/${encodeURI(f.path)}`}
41+
rel="external"
42+
download={f.path.split("/").pop()}
43+
title={`Download ${f.path}`}
44+
>
3945
{f.path}
4046
</a>
4147
<span class="tree__size">{formatBytes(f.size)}</span>

0 commit comments

Comments
 (0)