module Github::Repos::Downloads
def create_download(user, repo, params={})
POST /repos/:user/:repo/downloads
Response from this method is to be used in #upload method.
You must first create a new download resource using this method.
Creating a new download is a two step process.
def create_download(user, repo, params={}) _normalize_params_keys(params) raise ArgumentError, "expected following inputs to the method: #{REQUIRED_INPUTS.join(', ')}" unless _valid_inputs(REQUIRED_PARAMS, params) _filter_params_keys(VALID_PARAMS, params) post("/repos/#{user}/#{repo}/downloads", params) end
def delete_download(user, repo, download_id)
DELETE /repos/:user/:repo/downloads/:id
Delete download from a repository
def delete_download(user, repo, download_id) delete("/repos/#{user}/#{repo}/downloads/#{download_id}") end
def downloads(user, repo)
GET /repos/:user/:repo/downloads
List downloads for a repository
def downloads(user, repo) get("/repos/#{user}/#{repo}/downloads") end
def get_download(user, repo, download_id)
GET /repos/:user/:repo/downloads/:id
Get a single download
def get_download(user, repo, download_id) get("/repos/#{user}/#{repo}/downloads/#{download_id}") end
def upload(result, file)
the response object as an argument to upload method.
Github::Repos::Downloads#create. This can be done by passing
Upload a file to Amazon, using the reponse instance from
def upload(result, file) REQUIRED_S3_PARAMS.each do |key| raise ArgumentError, "expected following keys: #{REQUIRED_S3_PARAMS.join(', ')}" unless result.respond_to?(key) end # TODO use ordered hash if Ruby < 1.9 mapped_params = { "key" => result.path, "acl" => result.acl, "success_action_status" => 201, "Filename" => result.name, "AWSAccessKeyId" => result.accesskeyid, "Policy" => result.policy, "Signature" => result.signature, "Content-Type" => result.mime_type, "file" => file } post(result.s3_url, mapped_params) end