Skip to content

data.nemar.org file downloads return SHA-named files instead of BIDS-shaped filenames #513

Closed

Description

@neuromechanist

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-disposition returns attachment; 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

Activity

  1. neuromechanist commented on May 16, 2026

    @neuromechanist
    ContributorAuthor

    Shipped via PR #519 (epic→dev). Code is on dev and will flow to main in the next dev→main cycle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions