So with more development of the new Junior Youth + Us site, comes more new features that we needed. One of the things we thought about while developing the site previously was that we did not want to host all the images that were sent out way – instead we wanted to use another source. Of course there is AWS and all the CDN networks — but those cost money!
Instead we looked into the Imgur API which allowed us to upload images by just providing an API Key. I had already done this on PHP and unfortunately, there was no real “curl” function on Ruby, so I had to find an alternative method to upload images to Imgur. I went through a number of gems, however none of them seemed to work perfectly — that or I was just too stupid to figure out what I needed to do. Thus I decided to create my own gem for image uploads!
So after a few hours of work, I finally created Imgur-Ruby – my first attempt at a Ruby gem that is available to all. I’m actually quite surprised it works and how simple it actually is to use.
Here is how you set it up!
# Add your Imgur API Key from http://api.imgur.com @image = Imgurruby::Imgur.new('YOUR_API_KEY') # Uses the uploaded image file @image.upload(params[:file]) # The to access the URL # If there is an error, the error message will be displayed instead @image.url
It is that simple! If you would like to contribute to the Gem, please feel free to fork my repo here: