Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would one download a release asset #216

Open
rberger opened this issue Feb 18, 2015 · 3 comments
Open

How would one download a release asset #216

rberger opened this issue Feb 18, 2015 · 3 comments

Comments

@rberger
Copy link

rberger commented Feb 18, 2015

This seems to be an incredible mystery. I can't find any examples for any mechanism to programmatically download a release asset from a private repo.

I had hoped this Gem would have an easy way to do that, but I don't see how to do it here ether.

Any suggestions (or example code)?

Thanks

@piotrmurach
Copy link
Owner

Hi Robert,

The intro paragraph explains how to navigate the api and links to official docs. After reading official documentation for releases, you will find that the code hierarchy corresponds to with the docs. The api has over 200 methods and I took a lot of time to document the api calls with code examples - see release assets

github = Github.new ....
github.repos.releases.assets.get 'owner', 'repo', 'id'

@mjuarez
Copy link

mjuarez commented Apr 30, 2015

Excuse the messy Ruby, but this is what I had to do to wind up downloading a single asset:

def get_asset_download_url(github_user, github_repo, asset_id)
  api = Github.new
  resp = api.repos.releases.assets.get github_user, github_repo, asset_id, accept: 'application/octet-stream'
  return resp.headers.location
end

Two issues I came across was passing application/octet-stream to specify that I wanted a binary, then after that having to handle the redirect response GitHub will give.

Would be nice to see downloading to a file handle as an option.

@sarod
Copy link

sarod commented Sep 7, 2015

@rberger
I struggled to find it too but it's documented here https://developer.github.com/v3/repos/releases/#response-8
When getting a single asset setting header accept: application/octet-stream will download the asset as binary. Make sure to follow redirects (302).

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

No branches or pull requests

4 participants