Created
April 10, 2015 02:32
-
-
Save christoshrousis/ea6b5475c457ae666810 to your computer and use it in GitHub Desktop.
Ruby - Check if remote image url is valid
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 'open-uri' | |
require 'net/http' | |
def remote_file_exists?(url) | |
url = URI.parse(url) | |
Net::HTTP.start(url.host, url.port) do |http| | |
return http.head(url.request_uri)['Content-Type'].start_with? 'image' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment