Skip to content

Instantly share code, notes, and snippets.

@bricker
Created February 27, 2014 23:27
Show Gist options
  • Save bricker/9261922 to your computer and use it in GitHub Desktop.
Save bricker/9261922 to your computer and use it in GitHub Desktop.
require 'openssl'
require 'open-uri'
url = "https://i1.ytimg.com/vi/2K-8FJ114kU/hqdefault.jpg"
# Errors
response = open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
tempfile = Tempfile.new('youtube', encoding: "ascii-8bit")
tempfile.write response.read
Paperclip::Trimmer.make(tempfile) #=> convert error, "no decode delegate for this image format", "no images defined"
# Works
response = open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
tempfile = Tempfile.new('youtube', encoding: "ascii-8bit")
tempfile.write response.read
tempfile.rewind
Paperclip::Trimmer.make(tempfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment