Repository navigation
feat: fetch images and other attachments from issues and PRs - #121
Merged
Merged
Conversation
Fetch bodies with the full media type, harvest the short-lived signed URLs GitHub emits in body_html, download each referenced attachment to <output-dir>/attachments/<uuid>.<ext>, and rewrite issue/PR/comment bodies to relative paths so the synced tree is complete offline. Failed downloads keep the original URL and only warn. Refs: #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
sync-attachmentsinput (defaultfalse) that downloads attachments (images, videos, files) referenced in issue/PR bodies and comments to<output-dir>/attachments/<uuid>.<ext>and rewrites body URLs to relative paths, so the synced markdown tree is complete offline.Closes #2 — see the spike results for the investigation behind the mechanism.
How it works
application/vnd.github.full+jsonmedia type, so each response carriesbody_htmlalongside the raw markdown.body_html, GitHub has already rewritten every attachment (modernuser-attachments/assets/<uuid>and legacyuser-imagesURLs alike) to a pre-signed JWT URL onprivate-user-images.githubusercontent.comthat downloads with plain HTTP — uniformly for public and private repos. The JWT is valid ~5 min, so downloads happen inside the per-item sync loop.and<img src>forms are rewritten to../attachments/<uuid>.<ext>.hasContentChangedidempotency is preserved.modified-files;format-commandnow receives only markdown files.user-attachments/files/...) are downloaded directly, which works on public repos and may fail on private ones (no signed URL is emitted for them) — documented in the README.Testing
force-update, failure policy, andrun()wiring; 138/138 total pass.dist/index.jsagainst Bug: bright settings, icons in top bar not visible qx#136 (real attachment) — PNG downloaded byte-identical to a manual fetch, body rewritten to the relative path, and a second run is fully idempotent (no re-download, no rewrite).just precommit,just verify-dist, lint, andtscall green.Refs: #2