Groovy - File handling from http URL

前端 未结 4 1845
旧巷少年郎
旧巷少年郎 2021-01-03 12:32

The files in one of our servers can be accessed via http. So, when we bring up a url similar to the following, we get a list of files/directories in that location:



        
4条回答
  •  悲哀的现实
    2021-01-03 13:22

    I would think it would be far better to put an FTP server there, if you want to serve files.

    Unless your HTTP server supports a known file serving protocol such as WebDAV, you're going to have to jump through some hoops to use it as a file server.

    You would need to use a HTTP client, such as the Groovy HttpBuilder.

    When you make a request to that URL, your HTTP server returns a response. If you have directory listings enabled, then most HTTP servers will return a HTML page providing you with links to the files and subdirectories within that directory.

    You would need to parse that HTML response, perhaps using some regular expressions to extract the file links that you want from it.

    But every HTTP server returns such listings in its own format, so you would have to adapt it to the format used by your server.

提交回复
热议问题