JGithubPackageRepositoriesDownloads

Extends \JGithubPackage

GitHub API Repositories Downloads class for the Joomla Platform.

deprecated

The downloads API is for package downloads only. If you want to get source tarballs you should use https://developer.github.com/v3/repos/contents/#get-archive-link instead.

documentation

https://developer.github.com/v3/repos/downloads

since

1.7.3

deprecated

4.0 Use the joomla/github package via Composer instead

package

Joomla.Platform

Methods

__construct

Constructor.

__construct(\Joomla\Registry\Registry $options = null, \JGithubHttp $client = null) 
inherited
since

1.7.3

Arguments

$options

\Joomla\Registry\RegistryGitHub options object.

$client

\JGithubHttpThe HTTP client object.

__get

Magic method to lazily create API objects

__get(string $name) : \JGithubPackage
inherited
since

3.3

throws

\RuntimeException

Arguments

$name

stringName of property to retrieve

Response

\JGithubPackageGitHub API package object.

create

Create a new download (Part 1: Create the resource).

create(string $owner, string $repo, string $name, string $size, string $description = '', string $content_type = '') : object

Creating a new download is a two step process. You must first create a new download resource.

since

3.3

Arguments

$owner

stringThe name of the owner of the GitHub repository.

$repo

stringThe name of the GitHub repository.

$name

stringThe name.

$size

stringSize of file in bytes.

$description

stringThe description.

$content_type

stringThe content type.

Response

object

delete

Delete a download.

delete(string $owner, string $repo, integer $id) : object
since

3.3

Arguments

$owner

stringThe name of the owner of the GitHub repository.

$repo

stringThe name of the GitHub repository.

$id

integerThe id of the download.

Response

object

fetchUrl

Method to build and return a full request URL for the request. This method will add appropriate pagination details if necessary and also prepend the API url to have a complete URL for the request.

fetchUrl(string $path, integer $page, integer $limit) : string
inherited
since

1.7.3

Arguments

$path

stringURL to inflect

$page

integerPage to request

$limit

integerNumber of results to return per page

Response

stringThe request URL.

get

Get a single download.

get(string $owner, string $repo, integer $id) : object
since

3.3

Arguments

$owner

stringThe name of the owner of the GitHub repository.

$repo

stringThe name of the GitHub repository.

$id

integerThe id of the download.

Response

object

getList

List downloads for a repository.

getList(string $owner, string $repo) : object
since

3.3

Arguments

$owner

stringThe name of the owner of the GitHub repository.

$repo

stringThe name of the GitHub repository.

Response

object

processResponse

Process the response and decode it.

processResponse(\JHttpResponse $response, integer $expectedCode = 200, boolean $decode = true) : mixed
inherited
throws

\DomainException

since

3.3.0

Arguments

$response

\JHttpResponseThe response.

$expectedCode

integerThe expected "good" code.

$decode

booleanIf the should be response be JSON decoded.

Response

mixed

upload

Create a new download (Part 2: Upload file to s3).

upload(string $key, string $acl, string $success_action_status, string $filename, string $awsAccessKeyId, string $policy, string $signature, string $content_type, string $file) : boolean

Now that you have created the download resource, you can use the information in the response to upload your file to s3. This can be done with a POST to the s3_url you got in the create response. Here is a brief example using curl:

curl \ -F "key=downloads/octocat/Hello-World/new_file.jpg" \ -F "acl=public-read" \ -F "success_action_status=201" \ -F "Filename=new_file.jpg" \ -F "AWSAccessKeyId=1ABCDEF..." \ -F "Policy=ewogIC..." \ -F "Signature=mwnF..." \ -F "Content-Type=image/jpeg" \ -F "file=@new_file.jpg" \ https://github.s3.amazonaws.com/

NOTES The order in which you pass these fields matters! Follow the order shown above exactly. All parameters shown are required and if you excluded or modify them your upload will fail because the values are hashed and signed by the policy.

More information about using the REST API to interact with s3 can be found here: http://docs.amazonwebservices.com/AmazonS3/latest/API/

since

3.3

Arguments

$key

stringValue of path field in the response.

$acl

stringValue of acl field in the response.

$success_action_status

string201, or whatever you want to get back.

$filename

stringValue of name field in the response.

$awsAccessKeyId

stringValue of accesskeyid field in the response.

$policy

stringValue of policy field in the response.

$signature

stringValue of signature field in the response.

$content_type

stringValue of mime_type field in the response.

$file

stringLocal file. Example assumes the file existing in the directory where you are running the curl command. Yes, the @ matters.

Response

boolean

Properties

name

inherited
since

3.3

Type(s)

string

packages

inherited
since

3.3

Type(s)

array

options

Options for the GitHub object.

inherited
since

1.7.3

Type(s)

\Joomla\Registry\Registry

client

The HTTP client object to use in sending HTTP requests.

inherited
since

1.7.3

Type(s)

\JGithubHttp