Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
FileTest.exists? over HTTP
neilc
8/15/2006 6:17:00 PM
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...
)
puts "found file"
end
does not print found file even though the file exists
What am I doing wrong ?
Thanks in Advance
--
Posted via
http://www.ruby-...
.
2 Answers
khaines
8/15/2006 6:26:00 PM
0
Logan Capaldo
8/16/2006 4:52:00 AM
0
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...
)
> 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-...
.
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
FileTest.exists? over HTTP
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password