Skip to content

Improve URL-based file loading#825

Merged
PaulHax merged 5 commits intoKitware:mainfrom
PaulHax:urls
Nov 29, 2025
Merged

Improve URL-based file loading#825
PaulHax merged 5 commits intoKitware:mainfrom
PaulHax:urls

Conversation

@PaulHax
Copy link
Collaborator

@PaulHax PaulHax commented Nov 24, 2025

  • Content-Disposition header support: Extracts filenames from RFC 6266 headers, enabling loading from APIs without file extensions in URL paths
  • ZIP magic bytes detection: Detects ZIP files by signature regardless of extension, handling archives with generic Content-Type headers
  • URL parameter validation: Validates and normalizes URL parameters with support for comma-separated and bracket notation
  • ZIP archive filtering: Excludes LICENSE files from extraction to prevent load failures

- Add urlParams.ts utility for parsing and validating URL parameters
  - Validates URLs in the urls and config parameters
  - Supports comma-separated and bracket notation for multiple URLs
  - Filters out invalid URLs and logs errors

- Add ZIP magic bytes detection to file type identification
  - Detects ZIP files by PK header signature (0x50, 0x4b, 0x03, 0x04)
  - Enables loading of ZIP archives from URLs without .zip extension
  - Fixes loading DICOM files from APIs that return ZIP archives with
    generic Content-Type headers (e.g., application/octet-stream)

- Integrate URL parameter normalization in App.vue
  - Use normalizeUrlParams() to validate URLs before loading
  - Ensures only valid URLs are processed by the loading pipeline

This fixes issues with loading files from URLs that:
1. Return generic Content-Type headers
2. Have no file extension in the URL
3. Don't expose Content-Disposition via CORS headers
…tion

Add support for extracting filenames from Content-Disposition headers (RFC 6266) when loading files from URLs. This enables VolView to load files from APIs that don't include file extensions in their URL paths.

Priority order for filename detection:
1. Content-Disposition header (new)
2. URL path extension (existing)
3. Magic bytes (existing fallback)

Includes comprehensive e2e tests with custom Express test server.
@netlify
Copy link

netlify bot commented Nov 24, 2025

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit f29076e
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/6924962a91da4d0008f5c1f4
😎 Deploy Preview https://deploy-preview-825--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Only use Content-Disposition when name has no extension (indicating
URL-derived name like 'download' or 'getImage'). Names with extensions
are preserved, avoiding conflicts with explicit user-provided names.

- Removed second test case (wrong extension override not supported)
- Removed unused server endpoint
- Priority: Names with extension > Content-Disposition > Names without extension

Fix urls accept relative URLs in config parameter validationfix
- Add error handling for URL parameter parsing in App.vue

- Improve extension detection in openUriStream.ts
  - Use basename() and lastIndexOf('.') for robust extension check
  - Prevents false positives from hidden files and URL domains
@PaulHax
Copy link
Collaborator Author

PaulHax commented Nov 24, 2025

@zachmullen This touches a few of the ways VolView sniffs out the format of files. Curious about your thoughts on these techniques/hax if you get a chance.

@PaulHax PaulHax added this pull request to the merge queue Nov 29, 2025
Merged via the queue into Kitware:main with commit 0ac6a0c Nov 29, 2025
7 checks passed
@PaulHax PaulHax deleted the urls branch November 29, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants