amit170394 / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

doesResourceExist ? #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Firstly, nice project. Almost just what I need.

When directory browsing is off, can't easily identify if a file exists 
without having expense of retrieving it.

suggest something like:

    public boolean doesResourceExist(String url) throws 
SardineException
    {
        HttpGet get = new HttpGet(url);

        HttpResponse response = this.executeWrapper(get);

        StatusLine statusLine = response.getStatusLine();
        return SardineUtil.isGoodResponse(statusLine.getStatusCode
());
    }

Note this only works for Files, not folders. Not sure if you want to 
support this somehow or maybe just change the method name from 
doesresourceexist to doesfileexist ??

I'm planning on swapping out some FTP connects with WebDAV, hence looking 
for some like for like.

thanks

Original issue reported on code.google.com by goo...@techconz.com on 7 Jan 2010 at 9:00

GoogleCodeExporter commented 9 years ago
Yes, good suggestion. I'll see what webdav supports with regards to this. 

However, I'm pretty sure you can simulate it right now by using 
getResources("http://url/to/file.txt") and if you get back a result 
(list.size() == 1), 
then the file exists.

I'm not really sure what you mean by directory browsing being off. webdav works 
differently than httpd browsing does. It uses the propfind http method and all 
webdav servers need to support that.

Original comment by latch...@gmail.com on 7 Jan 2010 at 10:14

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r50.

Original comment by latch...@gmail.com on 7 Jan 2010 at 10:54

GoogleCodeExporter commented 9 years ago

Original comment by latch...@gmail.com on 8 Jan 2010 at 12:55