Skip to content

Add download command for PDF attachments#16

Merged
garaemon merged 4 commits intomainfrom
2026.04.01-download
Apr 7, 2026
Merged

Add download command for PDF attachments#16
garaemon merged 4 commits intomainfrom
2026.04.01-download

Conversation

@garaemon
Copy link
Copy Markdown
Owner

@garaemon garaemon commented Apr 3, 2026

Summary

  • Add download command to download all PDF attachments for a library item
  • Implement Sync API client with pagination support to fetch all server changes
  • Support --output / -o flag to specify download directory

Test plan

  • Unit tests for download command and API client
  • Manual test: ./paperpile-cli download <item_id> successfully downloads PDF

🤖 Generated with Claude Code

garaemon and others added 4 commits April 3, 2026 11:51
Introduce `paperpile download <item_id>` command that fetches a
presigned S3 URL from the API and downloads the PDF file locally.
Supports --output flag for specifying the output directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous implementation used a guessed /api/items/{id}/file endpoint.
Rewritten based on actual API investigation:

- Use Sync API (POST /api/sync?v=3 with last_server_sync=0) to fetch
  all attachment records from the Attachments collection
- Filter attachments by pub_id to find files for a library item
- Download via GET /api/attachments/{id}/file?type=latest (307 redirect to S3)
- Support multiple attachments per item and non-PDF file types
- Use attachment's filename field instead of hardcoded .pdf extension

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Sync API returns paginated results, but pullSyncData only fetched
the first page. This caused downloads to fail when the target item's
attachments were beyond the first page of results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@garaemon garaemon merged commit 31bae56 into main Apr 7, 2026
3 checks passed
@garaemon garaemon deleted the 2026.04.01-download branch April 7, 2026 05:58
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.

1 participant