class Github::Repos::Releases::Assets

The Release Assets API

def delete(*args)


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

Delete a release asset
def delete(*args)
  params = arguments(args, required: [:owner, :repo, :id]).params
  delete_request("/repos/#{owner}/#{repo}/releases/assets/#{id}", params)
end

def edit(*args)


"label": "Mac binary"
"name": "foo-1.0.0-osx.zip",
github.repos.releases.assets.edit 'owner', 'repo', 'id',
github = Github.new
= Examples

the asset. Used in place of the filename.
* :label - Optional string - An alternate short description of
* :name - Required string - the filename of the asset
= Inputs

Edit a release asset
def edit(*args)
  arguments(args, required: [:owner, :repo, :id]) do
    sift VALID_ASSET_PARAM_NAMES
  end
  params = arguments.params
  patch_request("/repos/#{owner}/#{repo}/releases/assets/#{id}", params)
end

def get(*args)


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

Get a single release asset
def get(*args)
  params = arguments(args, required: [:owner, :repo, :id]).params
  get_request("/repos/#{owner}/#{repo}/releases/assets/#{id}" , params)
end

def infer_media(filepath)


Infer media type of the asset
def infer_media(filepath)
  require 'mime/types'
  types = MIME::Types.type_for(filepath)
  types.empty? ? 'application/octet-stream' : types.first
rescue LoadError
  raise Github::Error::UnknownMedia.new(filepath)
end

def list(*args)


github.repos.releases.assets.list 'owner', 'repo', 'id' { |asset| ... }
github.repos.releases.assets.list 'owner', 'repo', 'id'
github = Github.new
= Examples

List assets for a release
def list(*args)
  params = arguments(args, required: [:owner, :repo, :id]).params
  response = get_request("/repos/#{owner}/#{repo}/releases/#{id}/assets", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def upload(*args)


"content_type": "application/octet-stream"
"name": "batman.jpg",
github.repos.releases.assets.upload 'owner', 'repo', 'id', 'file-path'
github = Github.new
= Examples

of the asset. Example: “application/zip”.
* :content_type - Required string - The content type
* :name - Required string - The file name of the asset
= Inputs

Upload a release asset
def upload(*args)
  arguments(args, required: [:owner, :repo, :id, :filepath]) do
    sift VALID_ASSET_PARAM_NAMES
  end
  params = arguments.params
  unless type = params['content_type']
    type = infer_media(filepath)
  end
  file = Faraday::UploadIO.new(filepath, type)
  options = {
    headers: { content_type: type },
    endpoint: 'https://uploads.github.com',
    query: {'name' => params['name']}
  }
  params['data']    = file.read
  params['options'] = options
  post_request("/repos/#{owner}/#{repo}/releases/#{id}/assets", params)
ensure
  file.close if file
end