Hello everybody,
I’m trying to allow users to download a file from a server (like a
Sharepoint one) with a link in my application.
Here is the view:
…
“Download the document”, :border => 0, :id => “icon”), d.document_url
%>
…
As you can see, i give an url to the link_to method. I would like to
know if the link is valid or not. I mean if it return really a file or
not.
I tried some methods like this one :
def remote_file_exist?(url)
res = Net::HTTP.get_response(URI.parse(URI.encode(url))) rescue
SocketError
res
end
This kind of method return an error for some valide urls and no error
for some invalide urls.
Have you any idea or suggestion ?