Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vanntastic-imgur

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanntastic-imgur

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

= imgur

A simple ruby interface to the imgur image hosting service (http://imgur.com). This is a nice alternative to uploading images and not having to deal with RMagick bs.

== Requirements

== Examples

Uploading an image to imgur from the filesystem

img = Imgur::API.new 'YOURAPIKEY' uploaded_img = img.upload_file '/path/to/your/test.jpg'

should return a hash like:

=> {"small_thumbnail"=>"http://imgur.com/NfuKFs.png",

    "original_image"=>"http://imgur.com/NfuKF.png", 
    "large_thumbnail"=>"http://imgur.com/NfuKFl.png", 
    "delete_hash"=>"VAiPkk5NoQ", "imgur_page"=>"http://imgur.com/NfuKF", 
    "delete_page"=>"http://imgur.com/delete/VAiPkk5NoQ", 
    "image_hash"=>"NfuKF"}

now you can do something like (if you're using rails):

<%= image_tag uploaded_img["small_thumbnail"] %>

Here's an example using Sinatra and Sequel, requires sinatra-more

Everything's included into one action for brevity, although you can probably extract the file functions to a helper for organizational purposes

post '/upload_photo' do # let's assume we have this is in our form # <%= file_field_tag :photo %> file_name = params[:photo][:filename].split(".").first.gsub!(/[^a-z0-9]+/i, '_') file_type = params[:photo][:filename].split(".").last tmp_file_path = File.join(APP_ROOT,"public/images/tmp/#{file_name}.#{file_type}") FileUtils.mv params[:photo][:tempfile].path, tmp_file_path

unless params["photo"].blank? || params["photo"].nil?
  @uploaded_img = IMGUR.upload_file tmp_file_path
end

@photo = Photo.new(:photo => @uploaded_img)
@photo.save

redirect '/results'

end

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2009 jdp. See LICENSE for details.

FAQs

Package last updated on 11 Dec 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc