assets
Creates, updates, deletes, gets or lists an assets resource.
Overview
| Name | assets |
| Type | Resource |
| Id | github.repos.assets |
Fields
The following fields are returned by SELECT queries:
- get_release_asset
- list_release_assets
Response
| Name | Datatype | Description |
|---|---|---|
id | integer | |
name | string | The file name of the asset. (example: Team Environment) |
node_id | string | |
browser_download_url | string (uri) | |
content_type | string | |
created_at | string (date-time) | |
digest | string | |
download_count | integer | |
label | string | |
size | integer | |
state | string | State of the release asset. (uploaded, open) |
updated_at | string (date-time) | |
uploader | object | A GitHub user. (title: Simple User) |
url | string (uri) |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer | |
name | string | The file name of the asset. (example: Team Environment) |
node_id | string | |
browser_download_url | string (uri) | |
content_type | string | |
created_at | string (date-time) | |
digest | string | |
download_count | integer | |
label | string | |
size | integer | |
state | string | State of the release asset. (uploaded, open) |
updated_at | string (date-time) | |
uploader | object | A GitHub user. (title: Simple User) |
url | string (uri) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_release_asset | select | owner, repo, asset_id | To download the asset's binary content: - If within a browser, fetch the location specified in the browser_download_url key provided in the response.- Alternatively, set the Accept header of the request to application/octet-stream. The API will either redirect the client to the location, or stream it directly if possible. API clients should handle both a 200 or 302 response. | |
list_release_assets | select | owner, repo, release_id | per_page, page | |
upload_release_asset | insert | owner, repo, release_id, name | label | This endpoint makes use of a Hypermedia relation to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the upload_url returned inthe response of the Create a release endpoint to upload a release asset. You need to use an HTTP client which supports SNI to make calls to this endpoint. Most libraries will set the required Content-Length header automatically. Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example: application/zipGitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example, you'll still need to pass your authentication to be able to upload an asset. When an upstream failure occurs, you will receive a 502 Bad Gateway status. This may leave an empty asset with a state of starter. It can be safely deleted.Notes: * GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets" endpoint lists the renamed filenames. For more information and help, contact GitHub Support. * To find the release_id query the GET /repos/{owner}/{repo}/releases/latest endpoint. * If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset. |
update_release_asset | update | owner, repo, asset_id | Users with push access to the repository can edit a release asset. | |
delete_release_asset | delete | owner, repo, asset_id |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
asset_id | integer | The unique identifier of the asset. |
name | string | |
owner | string | The account owner of the repository. The name is not case sensitive. |
release_id | integer | The unique identifier of the release. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
label | string | |
page | integer | The page number of the results to fetch. For more information, see "Using pagination in the REST API." |
per_page | integer | The number of results per page (max 100). For more information, see "Using pagination in the REST API." |
SELECT examples
- get_release_asset
- list_release_assets
To download the asset's binary content:
- If within a browser, fetch the location specified in the browser_download_url key provided in the response.
- Alternatively, set the Accept header of the request to
application/octet-stream.
The API will either redirect the client to the location, or stream it directly if possible.
API clients should handle both a 200 or 302 response.
SELECT
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url
FROM github.repos.assets
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND asset_id = '{{ asset_id }}' -- required
;
Response
SELECT
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url
FROM github.repos.assets
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND release_id = '{{ release_id }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- upload_release_asset
- Manifest
This endpoint makes use of a Hypermedia relation to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the upload_url returned in
the response of the Create a release endpoint to upload a release asset.
You need to use an HTTP client which supports SNI to make calls to this endpoint.
Most libraries will set the required Content-Length header automatically. Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example: application/zip
GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example,
you'll still need to pass your authentication to be able to upload an asset.
When an upstream failure occurs, you will receive a 502 Bad Gateway status. This may leave an empty asset with a state of starter. It can be safely deleted.
Notes:
* GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets"
endpoint lists the renamed filenames. For more information and help, contact GitHub Support.
* To find the release_id query the GET /repos/{owner}/{repo}/releases/latest endpoint.
* If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.
INSERT INTO github.repos.assets (
owner,
repo,
release_id,
name,
label
)
SELECT
'{{ owner }}',
'{{ repo }}',
'{{ release_id }}',
'{{ name }}',
'{{ label }}'
RETURNING
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url
;
# Description fields are for documentation purposes
- name: assets
props:
- name: owner
value: "{{ owner }}"
description: Required parameter for the assets resource.
- name: repo
value: "{{ repo }}"
description: Required parameter for the assets resource.
- name: release_id
value: {{ release_id }}
description: Required parameter for the assets resource.
- name: name
value: "{{ name }}"
description: Required parameter for the assets resource.
- name: label
value: "{{ label }}"
UPDATE examples
- update_release_asset
Users with push access to the repository can edit a release asset.
UPDATE github.repos.assets
SET
name = '{{ name }}',
label = '{{ label }}',
state = '{{ state }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND asset_id = '{{ asset_id }}' --required
RETURNING
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url;
DELETE examples
- delete_release_asset
No description available.
DELETE FROM github.repos.assets
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND asset_id = '{{ asset_id }}' --required
;