Gyazo
Gyazo API wrapper for Ruby
Install
% gem install gyazo
Usage
Register new application and get ACCESS TOKEN, then
Upload
require 'gyazo'
gyazo = Gyazo::Client.new access_token: 'your-access-token'
res = gyazo.upload imagefile: 'my_image.png'
puts res #=> {:type=>"png", :thumb_url=>"https://thumb.gyazo.com/thumb/...", :created_at=>"2019-05-03T11:57:35+0000", :image_id=>"...", :permalink_url=>"https://gyazo.com/...", :url=>"https://i.gyazo.com/....png"}
passing filename
if you give io for imagefile:
, you need filename:
.
gyazo.upload imagefile: File.open(image), filename: 'image.png'
Upload with metadata
Following attributes can be set
- created_at(default:
Time.now
) - referer_url(default: '')
- title(default: '')
- desc(default: '')
- collection_id(default: '')
res = gyazo.upload imagefile: 'my_image.png', created_at: Time.now, referer_url: 'https://example.com/'
List
gyazo.list[:images].each do |image|
puts image[:url]
end
image detail
gyazo.image image_id: image_id
Delete
gyazo.delete image_id: image_id
Test
setup
% gem install bundler
% bundle install
% export GYAZO_TOKEN=a1b2cdef3456 ## set your API Token
run test
% bundle exec rake test
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request