Module: Octokit::Client::Downloads
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/downloads.rb
Instance Method Summary collapse
-
#create_download(repo, name, options = {}) ⇒ Download
Create a download in a repository.
-
#delete_download(repo, id) ⇒ Object
Delete a single download for a repository.
-
#download(repo, id, options = {}) ⇒ Download
Get single download for a repository.
-
#downloads(repo, options = {}) ⇒ Array
(also: #list_downloads)
List available downloads for a repository.
Instance Method Details
#create_download(repo, name, options = {}) ⇒ Download
Create a download in a repository
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/octokit/client/downloads.rb', line 39 def create_download(repo, name, ={}) [:content_type] ||= 'text/plain' file = Faraday::UploadIO.new(name, [:content_type]) resource = create_download_resource(repo, file.original_filename, File.size(name), ) resource_hash = { 'key' => resource.path, 'acl' => resource.acl, 'success_action_status' => 201, 'Filename' => resource.name, 'AWSAccessKeyId' => resource.accesskeyid, 'Policy' => resource.policy, 'Signature' => resource.signature, 'Content-Type' => resource.mime_type, 'file' => file } conn = Faraday.new(resource.s3_url) do |builder| builder.request :multipart builder.request :url_encoded builder.adapter :net_http end response = conn.post '/', resource_hash response.status == 201 end |
#delete_download(repo, id) ⇒ Object
Delete a single download for a repository
73 74 75 |
# File 'lib/octokit/client/downloads.rb', line 73 def delete_download(repo, id) delete("repos/#{Repository.new(repo)}/downloads/#{id}", {}, 3, true, true, true) end |
#download(repo, id, options = {}) ⇒ Download
Get single download for a repository
25 26 27 |
# File 'lib/octokit/client/downloads.rb', line 25 def download(repo, id, ={}) get("repos/#{Repository.new(repo)}/downloads/#{id}", , 3) end |
#downloads(repo, options = {}) ⇒ Array Also known as: list_downloads
List available downloads for a repository
12 13 14 |
# File 'lib/octokit/client/downloads.rb', line 12 def downloads(repo, ={}) get("repos/#{Repository.new(repo)}/downloads", , 3) end |