Created
February 27, 2014 23:27
-
-
Save bricker/9261922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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