Monthly Archives: April 2013

Warning: S3::putObject(): RequestTimeTooSkewed – CarrierWave (Ruby on Rails)

Hey everyone,

Another issue I came across while working with CarrierWave. After rebooting a VM Amazon started too complain “request time too skewed”:

Warning: S3::putObject(): RequestTimeTooSkewed The difference between the request time and the current time is to large. in x on line 14

This one is another simple fix, just make sure your system time is correct. I’d been using a VM and it had run forward by a few hours. Setting it back manually resolved the error.

Amazon S3 Images Expiring – CarrierWave (Ruby on Rails)

Hey everyone,

After working with CarrierWave for a couple of days a few of my images started disappearing. It took a while to work out what was causing it, but thankfully the fix is pretty easy:

  2. #Set fog_public in your initialiser to true
  3. config.fog_public = false
  5. #Should be
  6. config.fog_public = true

Alternatively, if you’d like them to keep expiring but want to adjust their availability you can use the following config option:

  1. #Number of seconds
  2. config.fog_authenticated_url_expiration = 60000

There’s a bit of info in the following StackOverflow post:

Retrieving Thumbnail from an Animated Gif – CarrierWave

Hey everyone,

I’ve been mucking around with CarrierWave today and ran into a bit of an issue. When creating a thumbnail from an animated gif the thumbnail was also animated. Unfortunately this led to some of my image-heavy pages hanging for a bit.

This StackOverflow post offers the following solution:

  2. #Add this method in your uploader
  3. def remove_animation
  4.   manipulate! do |img, index|
  5.     index == 0 ? img : nil
  6.   end
  7. end
  10. #Adjust your thumbnail process so that it now includes a call to the new function
  11. version :thumb do
  12.   process :remove_animation
  13.   process :resize_to_limit => [75, 75]
  14.   process :convert => 'jpg'
  15. end

Excon::Errors::SocketError Broken pipe (Errno::EPIPE) – Ruby on Rails

Hey everyone,

I was having a bit of trouble with CarrierWave on Amazon S3 today. When attempting to upload files that were larger than ~150kb I received one of the following errors (depending on config):

getaddrinfo: Name or service not known carrierwave
Excon::Errors::SocketError in PhotosController#create
Broken pipe (Errno::EPIPE)


Despite the vague error, the solution was fairly simple. The region configured in my initialiser was different to the one my bucket was created in.

In order to find out which region you need, logon to your AWS console and browse to an uploaded image. Check the endpoint URL (properties > static website hosting) and simply copy the region. For examples:

Region: us-west-2

A couple of final tips if this doesn’t work for you:

  • You need the region codes, not the name. For instance, “Oregon” won’t work
  • Don’t forget to restart your app after making changes to the initialiser

    Remote JSON Source – Ruby on Rails

    Hey everyone,

    Just a quick post on how to retrieve a remote JSON source so I don’t forget.

    1. require 'open-uri'
    2. require 'json'
    4. #Retrieve source (controller/model)
    5. @results = JSON.parse(open("").read)
    8. #In view
    9. <% @results.each do |result| %>
    10.    <%= result['value'] %>
    11. <% end %>

    That’s all there is to it, let me know if you have any problems!

    Blank Row in Select_Tag – Ruby on Rails

    Hey everyone,

    Just a quick post on how to include a blank row or prompt value when using a select_tag in rails:

    2. #Prompt
    3. <select_tag "Animals", animals_as_options, :prompt => "Please select an animal" />
    5. #Blank option
    6. <select_tag "Animals", animals_as_options, :include_blank => true />

    Let me know if you have any issues.