Skip to content

feat: preserve file extensions in upload URLs - #92

Merged
anoncam merged 2 commits into
mainfrom
feature/preserve-file-extensions
Oct 7, 2025
Merged

anoncam merged 2 commits into
mainfrom
feature/preserve-file-extensions

Conversation

@anoncam

@anoncam anoncam commented Oct 7, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes #90 - Adds proper file extension preservation for file uploads and downloads.

When uploading files using dedpaste --file somefile.pdf, the original filename and extension are now preserved in the retrieval URL, allowing proper file type identification upon download.

Changes Made

  • CLI Updates: Modified cli/index.ts to send X-Filename header with the basename of uploaded files
  • Three upload paths updated:
    1. Send command (both encrypted and non-encrypted)
    2. Default command (encrypted uploads)
    3. Default command (non-encrypted uploads)
  • Version bump: Updated to 1.18.0 (minor feature addition)

Technical Details

The server-side code already supported this feature:

  • Accepts X-Filename header and stores it in R2 metadata
  • Supports optional filename in URL paths: /{id}/{filename} and /e/{id}/{filename}
  • Returns URLs with filename when metadata contains it

The gap was that the CLI never sent the filename header. This PR closes that gap.

Before/After Examples

Before

$ dedpaste --file document.pdf
https://paste.d3d.dev/AbCdEfGh

After

$ dedpaste --file document.pdf
https://paste.d3d.dev/AbCdEfGh/document.pdf

$ dedpaste --file photo.jpg --encrypt
https://paste.d3d.dev/e/XyZ123/photo.jpg

$ dedpaste --file data.json --temp
https://paste.d3d.dev/AbCdEfGh/data.json

Use Cases Addressed

  • ✅ Binary files (PDFs, images, videos) get proper extensions
  • ✅ Automation scripts can determine file handling based on extension
  • ✅ Cross-platform sharing with proper file type associations
  • ✅ Web browsers can set proper MIME types and Content-Disposition headers

Test Plan

  • Build succeeds with TypeScript compilation
  • CLI code review confirms proper header injection
  • All three upload code paths include the filename header
  • Manual testing with actual file uploads (requires deployment)

🤖 Generated with Claude Code

anoncam and others added 2 commits October 7, 2025 09:54
- Add X-Filename header to all file upload requests in CLI
- Server already supports filename in URL path and metadata
- Update CLI to send basename of uploaded file to server
- Affects both encrypted and non-encrypted uploads
- Resolves #90

When uploading files using --file flag, the original filename
is now included in the returned URL, allowing proper file type
identification:
- Before: https://paste.d3d.dev/AbCdEfGh
- After: https://paste.d3d.dev/AbCdEfGh/document.pdf

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@anoncam
anoncam merged commit 5f4d8d8 into main Oct 7, 2025
2 checks passed
github-actions Bot added a commit that referenced this pull request Oct 7, 2025
Version bump type: minor
PR: #92
Title: feat: preserve file extensions in upload URLs
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.

Add proper file extensions for file uploads and downloads

1 participant