class JGithubPackageRepositoriesDownloads extends JGithubPackage

GitHub API Repositories Downloads class for the Joomla Platform.

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.

Methods

__construct( Registry $options = null, JGithubHttp $client = null)

Constructor.

__get( string $name)

Magic method to lazily create API objects

object
getList( string $owner, string $repo)

List downloads for a repository.

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

Get a single download.

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

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

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

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

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

Delete a download.

Details

__construct( Registry $options = null, JGithubHttp $client = null)

Constructor.

Parameters

Registry $options GitHub options object.
JGithubHttp $client The HTTP client object.

JGithubPackage __get( string $name)

Magic method to lazily create API objects

Parameters

string $name Name of property to retrieve

Return Value

JGithubPackage GitHub API package object.

Exceptions

RuntimeException

object getList( string $owner, string $repo)

List downloads for a repository.

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.

Return Value

object

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

Get a single download.

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
integer $id The id of the download.

Return Value

object

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

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

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

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
string $name The name.
string $size Size of file in bytes.
string $description The description.
string $content_type The content type.

Return Value

object

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

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

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/newfile.jpg" \ -F "acl=public-read" \ -F "successactionstatus=201" \ -F "Filename=newfile.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/

Parameters

string $key Value of path field in the response.
string $acl Value of acl field in the response.
string $success_action_status 201, or whatever you want to get back.
string $filename Value of name field in the response.
string $awsAccessKeyId Value of accesskeyid field in the response.
string $policy Value of policy field in the response.
string $signature Value of signature field in the response.
string $content_type Value of mime_type field in the response.
string $file Local file. Example assumes the file existing in the directory where you are running the curl command. Yes, the @ matters.

Return Value

boolean

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

Delete a download.

Parameters

string $owner The name of the owner of the GitHub repository.
string $repo The name of the GitHub repository.
integer $id The id of the download.

Return Value

object