From: Logan Capaldo Date: 2006-08-16T13:51:55+09:00 Subject: Re: FileTest.exists? over HTTP On Aug 15, 2006, at 2:16 PM, Neil Charlton wrote: > HI > > I would like to test for the existence of a file over HTTP. I have > tried > various combinations of File.stat and FileTest.exists? with no > results. > > For example (image.jpg exists) > > if FileTest.exists?("http://domain.com/image.jpg") > puts "found file" > end > > does not print found file even though the file exists > > What am I doing wrong ? > As Kirk mentioned, the only transparent url support is with open-uri. Also File.exists? does not really make sense for a url. A given url does not necessarily point to a real file. Does it exist if you get a response code of 200? What about 302? What about 404? Sure the webserver says it doesn't exist, but you do get some content back usually. > Thanks in Advance > > > > -- > Posted via http://www.ruby-forum.com/. >