JGithubPackageRepositoriesDownloads
Extends \JGithubPackageGitHub 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.
documentation | |
---|---|
since |
1.7.3 |
deprecated |
4.0 Use the |
package |
Joomla.Platform |
Methods
__construct
Constructor.
__construct(\Joomla\Registry\Registry $options = null, \JGithubHttp $client = null)
since |
1.7.3 |
---|
Arguments
- $options
\Joomla\Registry\Registry
GitHub options object.- $client
\JGithubHttp
The HTTP client object.
__get
Magic method to lazily create API objects
__get(string $name) : \JGithubPackage
since |
3.3 |
---|---|
throws |
|
Arguments
- $name
string
Name of property to retrieve
Response
\JGithubPackage
GitHub 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 $contentType = '') : object
Creating a new download is a two step process. You must first create a new download resource.
since |
3.3 |
---|
Arguments
- $owner
string
The name of the owner of the GitHub repository.- $repo
string
The name of the GitHub repository.- $name
string
The name.- $size
string
Size of file in bytes.- $description
string
The description.- $contentType
string
The content type.
Response
object
delete
Delete a download.
delete(string $owner, string $repo, integer $id) : object
since |
3.3 |
---|
Arguments
- $owner
string
The name of the owner of the GitHub repository.- $repo
string
The name of the GitHub repository.- $id
integer
The 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
since |
1.7.3 |
---|
Arguments
- $path
string
URL to inflect- $page
integer
Page to request- $limit
integer
Number of results to return per page
Response
string
The request URL.
get
Get a single download.
get(string $owner, string $repo, integer $id) : object
since |
3.3 |
---|
Arguments
- $owner
string
The name of the owner of the GitHub repository.- $repo
string
The name of the GitHub repository.- $id
integer
The id of the download.
Response
object
getList
List downloads for a repository.
getList(string $owner, string $repo) : object
since |
3.3 |
---|
Arguments
- $owner
string
The name of the owner of the GitHub repository.- $repo
string
The name of the GitHub repository.
Response
object
processResponse
Process the response and decode it.
processResponse(\JHttpResponse $response, integer $expectedCode = 200, boolean $decode = true) : mixed
throws |
|
---|---|
since |
3.3.0 |
Arguments
- $response
\JHttpResponse
The response.- $expectedCode
integer
The expected "good" code.- $decode
boolean
If 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 $successActionStatus, string $filename, string $awsAccessKeyId, string $policy, string $signature, string $contentType, 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 "[email protected]_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
string
Value of path field in the response.- $acl
string
Value of acl field in the response.- $successActionStatus
string
201, or whatever you want to get back.- $filename
string
Value of name field in the response.- $awsAccessKeyId
string
Value of accesskeyid field in the response.- $policy
string
Value of policy field in the response.- $signature
string
Value of signature field in the response.- $contentType
string
Value of mime_type field in the response.- $file
string
Local file. Example assumes the file existing in the directory where you are running the curl command. Yes, the @ matters.
Response
boolean
Properties
name
since |
3.3 |
---|
Type(s)
string
packages
since |
3.3 |
---|
Type(s)
array
client
The HTTP client object to use in sending HTTP requests.