Skip to content

Download attachment/file from an issue/pr #9046

Open

Description

@chubin

Describe the feature or problem you’d like to solve

I know that it is not possible to upload files to issues programmatically, but it would be helpful to at least be able to download files. At the moment, as far as I understand, it is not possible either.

This would allow users to automatically process issues with attachments in their bodies and comments.

Proposed solution

Add a new command that will download a file referred to in the issue by its URL

gh issue download URL

Activity

  1. added
    enhancement
    on May 4, 2024
  2. added
    needs-triage
    on May 4, 2024
  3. added
    gh-issue
    on May 7, 2024
  4. andyfeller commented on May 7, 2024

    @andyfeller
    Contributor

    @chubin : Thanks for bringing up this suggestion! ❤

    Could you share a little more about the use case in question? How are you envisioning this being used by GitHub CLI users?

    I know there have been times where I've attached files to an issue for diagrams or PDFs, but I haven't really considered what I'd attach to issue / PR / discussion that'd I wouldn't commit to the repo. 🤔

    I know that it is not possible to upload files to issues programmatically, but it would be helpful to at least be able to download files. At the moment, as far as I understand, it is not possible either.

    Sadly, I think you're right: there are no APIs around attachments — whether release, issue, pull request, or discussion — to make something like this easy.

    Without them, the best anyone could do is pulling the main issue body and every issue comment looking for specific GitHub domains like *.githubassets.com, *.githubusercontent.com. This sounds like a great idea for someone wanting to hack on a GitHub CLI extension.

  5. removed
    needs-triage
    on May 7, 2024
  6. chubin commented on May 8, 2024

    @chubin
    Author
  7. jgunstone commented on Sep 26, 2024

    @jgunstone

    hi there -
    I'm after the same thing so thought I'd describe another use case -

    I'm a engineer and developer, in a company of majority non-coding engineers. My team have adopted Github for all our project planning and we use the github CLI to retrieve this issue / project data and report to the rest of the practice.

    Ideally this data would be able to include images - currently I can only show text.

  8. added
    extension-idea
    on Sep 26, 2024
  9. vim-usds commented on Sep 29, 2024

    @vim-usds

    It would be so awesome to have this capability in the CLI.

    Here's a workflow file that is able to grab an XLS attachment from the body of an issue that is created with an attachment label:

    Details
    name: Get Attachment from issue
    
    on:
      issues:
        types: [opened]
    
    jobs:
      get-attachment-job:
        if: >
          contains(github.event.issue.labels.*.name, 'attachment') &&
          github.event.sender.login != 'github-actions[bot]'
        runs-on: ubuntu-latest
        permissions:
          contents: write
          pull-requests: write
          issues: read
        steps:
          - uses: actions/checkout@v4
          - name: Download file from issue
            id: download
            env:
              GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            run: |
              ISSUE_NUMBER="${{ github.event.issue.number }}"
              echo "Issue number: $ISSUE_NUMBER"
    
              # Check GitHub API rate limits before proceeding
              echo "Checking GitHub API rate limits..."
              gh api rate_limit
    
              # Fetch issue data
              echo "Fetching issue data..."
              ISSUE_DATA=$(gh issue view $ISSUE_NUMBER --json number,title,body,comments)
              echo "Issue data:"
              echo "$ISSUE_DATA" | jq '.'
    
              # Try to find attachment in issue body
              ATTACHMENT_URL=$(echo "$ISSUE_DATA" | jq -r '.body' | grep -oP 'https://github.com/user-attachments/files/[^/]+/[^)]+\.xls' | head -n 1)
    
              if [ -z "$ATTACHMENT_URL" ]; then
                echo "No attachment found in issue body. Checking comments..."
                ATTACHMENT_URL=$(echo "$ISSUE_DATA" | jq -r '.comments[].body' | grep -oP 'https://github.com/user-attachments/files/[^/]+/[^)]+\.xls' | head -n 1)
              fi
              if [ -z "$ATTACHMENT_URL" ]; then
                echo "No attachment found in issue or comments."
                exit 1
              fi
    
              echo "Attachment URL: $ATTACHMENT_URL"
    
              # Download the attachment
              echo "Downloading attachment..."
              curl -L -o myAttachment.xlsx "$ATTACHMENT_URL"
    
              echo "Attachment downloaded successfully."
    
          - name: Upload attachment as artifact
            uses: actions/upload-artifact@v4
            with:
              name: "My issue attachment"
              path: ./myAttachment.xlsx
    
  10. andyfeller commented on Oct 7, 2024

    @andyfeller
    Contributor

    Unfortunately, this type of feature is blocked because GitHub APIs don't support issue and PR attachments.

    I speculate there is an abuse concern here of people being able to attach arbitrary files outside of repository contents. As far as I know, the only support is through the GitHub web interface for uploading and accessing attachments. 😞

  11. chuanqisun commented on Jul 25, 2025

    @chuanqisun

    +1 for a user need on this API. My team wants user to upload logs and screenshots in their bug report or feature request. We want to programmatically access the screenshot files so a coding AI can analyze the issue using vision AI models. This would be something that github's own copilot agent can benefit from too.

  12. psugihara commented on Oct 19, 2025

    @psugihara

    Another use case: Claude Code is excellent at completing simple issues that I point to by issue number. However, for small UI tweaks where screenshots provide crucial context, I need to manually download them and feed them to the agent. It would be great if the agent could simply retrieve this context via the CLI, as they do for all other context.

  13. stevemadere commented on Oct 31, 2025

    @stevemadere

    This is an absolute requirement for an AI agent that works a queue of issues assigned to it.

    Often, the only efficient way to communicate GUI requirements is with an illustration of the desired feature.

  14. psugihara commented on Oct 31, 2025

    @psugihara

    FYI, this in my CLAUDE.md works pretty well to get claude completing GitHub issues and download attached images:

    ## Completing GitHub Issues
    
    - Create commits with descriptive messages referencing the issue number
    - Lint and test before opening a PR
    - If there's UI, don't open a PR. Start a dev server and link the user to the feature.
    - Use `gh` CLI for GitHub operations
    - View issue: `gh issue view <number>` (consider title, body, and comments)
    - Download images from issues: `curl -H "Authorization: token $(gh auth token)" -L <image-url> -o image.png`
    
  15. bric3 commented on Jan 22, 2026

    @bric3
    • Even for IDEs that integrate GitHub, this would be useful.
    • For back-ups.
  16. added
    platform
    on Jan 22, 2026
  17. BagToad commented on Jan 22, 2026

    @BagToad
    Member

    Hi folks, please open a GitHub support ticket to request this API - generally requests in this repository are monitored by the CLI maintainers and not the platform developers.

  18. drogers0 commented on Sep 8, 2026

    @drogers0

    gh-image banner

    While waiting on something first party, gh-image does this today:

    gh image download <url>...

    Works on private attachments with your gh token. No browser needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedenhancementextension-ideagh-issueplatform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions