Which file access is the best : Webdav or FTP?

I have to develop a Java application that has to read some files on the network, edit them and put them back.

The problem is that I always did (over the network) file operations through the FTP protocol. But, I recently heard about Webdav which is HTTP based.

Did anyone notice a difference (in terms of speed) between them ? Which one is the best ? Why did they "invent" Webdav if the FTP is good for that?


WebDAV has the following advantages over FTP:

  • By working via one TCP connection it's easier to configure it to bypass firewalls, NATs and proxies. In FTP the data channel can cause problems with proper NAT setup.

  • Again due to one TCP connection, which can be persistent, WebDAV would be a bit faster than FTP when transferring many small files - no need to make a data connection for each file.

  • GZIP compression is a standard for HTTP but not for FTP (yes, MODE Z is offered in FTP, but it's not defined in any standard).

  • HTTP has wide choice of authentication methods which are not defined in FTP. Eg. NTLM and Kerberos authentication is common in HTTP and in FTP it's hard to get proper support for them unless you write both client and server sides of FTP.

  • WebDAV supports partial transfers and in FTP partial uploads are not possible (ie. you can't overwrite a block in the middle of the file).

  • There's one more thing to consider (depending on whether you control the server) - SFTP (SSH File Transfer Protocol, not related to FTP in any way). SFTP is more feature-rich than WebDAV and SFTP is a protocol to access remote file systems, while WebDAV was designed with abstraction in mind (WebDAV was for "documents", while SFTP is for files and directories). SFTP has all benefits mentioned above for WebDAV and is more popular among both admins and developers.


    Answer for question - Why did they "invent" Webdav

    WebDAV stands for Web Distributed Authoring and Versioning .

    Internet was just not meant for consumption of resources through urls (Uniform resource locator)

    But that is what it became.

    Because HTTP had strong semantics for fetching resources (GET) and (HEAD). (POST) provided coverage for number of semantic operations while (DELETE) was shrouded in distrust. HTTP lacked some other qualities like multi-resource operations.

    In nutshell, it was read protocol and not write protocol.

    You would go round about to make your resources (URLs) available for fetching by uploading it though FTP and many number of mechanisms.

    WebDAV was supposed to provide the missing story of internet : Support for authoring resource through the same mechanism HTTP. It extended its semantics, introduced new HTTP VERBS.

    It also introduced the mechanism to not only read, write, modify and delete a resource (uris) but also make inquires on the meta properties of the resource and modify it. It is not that you could not do it before but it was done through back door mechanism.

    So you see, it brought some of the same mechanisms that you expect on file operations on desktop to internet resources.

    Following are some of the analogies:

    MKCOL     ----- make collection ----- similar to make folder
    PROPGET   ---- get properties (meta?) --- same as get info or extended attributes on mac
    PROPPATCH --- modify properties
    COPY      ---- cp
    MOVE      ---- mv
    

    I hope , I have established some of the noble goals of WebDAV as extension to HTTP to support internet authoring. Not sure if we have achieved it though.

    For your question

    Your application is a client and will have to make do with what mechanism is available - FTP or WebDAV on the other side. If WebDAV is available great, you can use it. But It will take some time getting used to the semantics. FTP is has limited semantics and excels in simplicity. If you are already using it, don't change it.

    Which is faster

    That is akin to answering, which is faster HTTP or FTP?

    On a sly note, if it was such an issue we wouldn't have been downloading / uploading files via HTTP ;)


    Since DAV works over HTTP , you get all the benefits of HTTP that FTP cannot provide.

    For example:

    strong authentication, encryption, proxy support, and caching.

    It is true that you can get some of this through SSH, but the HTTP infrastructure is much more widely deployed than SSH. Further, SSH does not have the wide complement of tools, development libraries, and applications that HTTP does.

    DAV transfers (well, HTTP transfers) are also more efficient than FTP. You can pipeline multiple transfers through a single TCP connection, whereas FTP requires a new connection for each file transferred (plus the control connection).

    Reference

    链接地址: http://www.djcxy.com/p/61362.html

    上一篇: 通过FTP协议从iPhone上传/下载文件

    下一篇: 哪个文件访问最好:Webdav或FTP?