Repository navigation
Description
Symptom
When a user (or rclone, or aria2c) hits `https://data.nemar.org///`, the Worker 302-redirects to a presigned S3 URL pointing at the content-addressed object. The browser then downloads the file with the SHA-named basename rather than the BIDS-shaped basename the user expects.
Example: clicking the EDF link for sub-01438774_ses-1625258895_task-typing_emg.bdf on the nm000104 detail page saves to disk as:
SHA256E-s197576448--c70cae6e4a043e2124d7e5ee94422d02.bdf
Reproduce:
curl -sIL "https://data.nemar.org/nm000104/v2.0.0/sub-01438774/ses-1625258895/emg/sub-01438774_ses-1625258895_task-typing_emg.bdf" | grep -i 'content-disposition\|location'The 302 `Location` header points at the SHA-named object; the final S3 response has no `Content-Disposition: attachment; filename=...` header, so the browser falls back to the URL basename, which is the SHA.
Why this matters
- Web users see meaningless filenames after one click.
- rclone and aria2c users get a directory full of SHA-named files instead of BIDS-shaped ones. The BIDS validator can't read them without renaming.
- HTML `` doesn't work for cross-origin downloads, so the website frontend can't fix this on its own.
Fix
In backend/src/services/data-router.ts, the buildRedirectUrl function (or whichever helper presigns the S3 URL on the 302 path) should add a response-content-disposition query parameter so the presigned URL carries the desired filename:
// Pseudo:
const filename = bidsPath.split("/").pop()!;
const params = new URLSearchParams({
"response-content-disposition": `attachment; filename="${encodeRFC5987(filename)}"`,
});
const presigned = signS3Url(bucket, objectKey, { extraParams: params, ...other });S3 will then return `Content-Disposition: attachment; filename="sub-01...bdf"` on the actual GET, and every client (browser, rclone, aria2c, curl) saves with the BIDS name.
Notes:
- Use RFC 5987 encoding for non-ASCII filenames so umlauts etc. survive.
- The same fix applies to the README/dataset_description.json paths once
nemarOrg/nemar-cli#509's fix flows through (small root files in the manifest).
Acceptance
curl -sIL "https://data.nemar.org/nm000104/v2.0.0/sub-01438774/.../task-typing_emg.bdf" | grep -i content-dispositionreturnsattachment; filename="sub-01438774_ses-..._emg.bdf"(the BIDS name)- Browser "Save Link As" on the dataset detail page proposes the BIDS filename
rclone copy :http:data.nemar.org/nm000104/v2.0.0/ ./produces a directory tree with BIDS-shaped filenames
Frontend nudge already shipped
nemarOrg/website (commit 44bbfb1) now routes every tree download through data.nemar.org/<id>/<v>/<path> instead of the direct manifest `url` field, putting the Worker in the chain. Once this issue is fixed, the website's file links will start producing BIDS-shaped downloads immediately with no further frontend change.
Related
- S3 dataset/ prefix: tool-agnostic cloud-like access to NEMAR datasets #449 (data.nemar.org epic)
- Manifest generator drops small regular git files at dataset root (README, CHANGES, dataset_description.json) #509 (manifest small-root-files fix — merged)
- QA artifacts sync from hallu + data.nemar.org/<id>/qa/* route #511 (QA artifacts route — Phase 3 backend)
- OpenNeuro import path doesn't backfill modalities, tasks, subject_count into the D1 catalog #512 (OpenNeuro import metadata backfill)
Activity
Phase 1: force BIDS filenames on data.nemar.org downloads (#513) (#515)
neuromechanist commentedon May 16, 2026
Shipped via PR #519 (epic→dev). Code is on
devand will flow tomainin the next dev→main cycle.