Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby Remote File Checker

DZone's Guide to

Ruby Remote File Checker

·
Free Resource

require 'rubygems'
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).code == "200"
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}