Gyazo API wrapper for Ruby
% gem install gyazo
Register new application and get ACCESS TOKEN, then
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"}
if you give io for imagefile:
, you need filename:
.
gyazo.upload imagefile: File.open(image), filename: 'image.png'
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/'
gyazo.list[:images].each do |image|
puts image[:url]
end
gyazo.image image_id: image_id
gyazo.delete image_id: image_id
setup
% gem install bundler
% bundle install
% export GYAZO_TOKEN=a1b2cdef3456 ## set your API Token
run test
% bundle exec rake test
- 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