Skip to content

feat(download): v2 file download via /files/{fileId} + X-C4GH-Public-Key #677

@jhagberg

Description

@jhagberg

Part of #663. Depends on #676.

Please describe the feature
As a data recipient, I want download --api-version v2 to fetch files by fileId through the v2 re-encrypted Crypt4GH path, so my existing CLI commands keep working against the new server.

This is also where DownloadFile joins the Client interface and the legacy download.downloadFile / getFileIDURL go away. Deferred from #674 because it requires splitting the existing downloadFile (HTTP fetch + progress-bar write) into two pieces.

Acceptance criteria

  • Client interface: add DownloadFile(ctx, DownloadRequest) (io.ReadCloser, int64, error) and DownloadRequest type
  • V1Client.DownloadFile: absorbs the resolution logic from download.getFileIDURL (substring match kept) and the HTTP-fetch half of download.downloadFile. Returns the raw body for the caller to stream
  • V2Client.DownloadFile:
    • Resolves UserArg via ListFiles({ExactPath: ...}) for paths, list-and-match for bare IDs
    • Follows FileInfo.DownloadURL (server-provided; client does not construct /files/{id})
    • Sends X-C4GH-Public-Key (base64 of the raw 32-byte key preferred)
    • 403 surfaces as ambiguous "dataset/file does not exist or access denied"
  • apiclient.File gains a DownloadURL field (empty on v1)
  • download.writeBodyToDisk(body, totalSize, destPath) extracted from downloadFile. Progress bar and .part handling unchanged
  • datasetCase / recursiveCase / fileCase call client.DownloadFile + writeBodyToDisk
  • Deleted (all callers migrated): download.GetDatasets, download.GetFilesInfo, download.File alias, download.getFileIDURL, download.downloadFile
  • download --api-version v2 without --pubkey errors client-side with a clear message
  • End-to-end integration test: download the seeded file via v2, check body size matches Content-Length
  • Tests verifying the changes are added

Additional context
UX change: --pubkey is effectively required on v2. v1 currently accepts downloads without it; v2 will not. Document this in the PR description.

Estimation of size: big

Estimation of priority: high

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions