通过Java进行的WebDAV身份验证

huangapple go评论58阅读模式
英文:

WebDAV authentication through Java

问题

我做了一个程序,可以将文件从手机复制到Windows文件夹。通过WebDAV服务器连接手机。问题是,我不能在没有打开例如 htpp://192.168.1.40:8080 在我的Windows资源管理器中的情况下,通过Java连接到手机。在那之后,手机在Java中可见。但这破坏了我程序的全部意义。

有人知道如何首先通过Java访问手机吗?我需要更改注册表中的某些内容吗?

非常感谢!

附:复制过程如下:

File src = new File("\\" + address + "\\DavWWWRoot\\DCIM\\Camera");

其中,address 为 "192.168.x.xx:8080"

然后程序继续执行 Files.walkFileTree 以复制所有文件。

英文:

I've made a program which copies files from phone to windows folder. Connection to phone via WebDAV server. The problem is that I cannot connect to phone through Java until I open for ex. htpp://192.168.1.40:8080 in my windows explorer. After that phone is visible in Java. But that ruins all the meaning of my program.

Does anyone knows how to get access to phone through Java in the first place? Do I need to change something in registry or?

Thanks a lot!

P.S. copying procedure goes by:

File src = new File("\\\\" + address + "\\DavWWWRoot\\DCIM\\Camera");

where address is "192.168.x.xx:8080"

and then it goes to Files.walkFileTree to copy all the files.

答案1

得分: 1

你必须使用WebDAV客户端,如果你不想依赖操作系统。我建议使用Apache Virtual Filesystem(VFS)。它在不同类型的文件系统上提供了额外的一层,并且似乎也支持WebDAV。

https://commons.apache.org/proper/commons-vfs/index.html

英文:

You have to use a WebDAV client if you do not want to rely on the OS. I suggest Apache Virtual Filesystem (VFS). It provides an additional layer over different types of filesystems and seems to have also support for WebDAV.

https://commons.apache.org/proper/commons-vfs/index.html

答案2

得分: 0

好的,以下是已翻译的部分:

嗯...我想出了一种略微不同但最简单的方法来解决我的问题。

整个问题就出在这个该死的Windows操作系统上。它默认按需拥有WebClient服务。我将它切换为自动,现在我可以在重新启动后连接到手机(或任何其他WebDAV服务器)。

切换为自动WebClient服务的CMD代码:

sc config webclient start=auto

以管理员身份运行。

附注:不过我不得不承认,我从WebDAV服务器复制文件的方式(walkFileTree)可能远非最佳。

英文:

Well..I've made a bit different but most simplest way to solve my problem.

The whole problem was in this goddamn Windows OS. It has WebClient service on demand by default. I switched it to auto and now I can connect to phone (or any other WebDAV server) after reboot.

CMD code to switch to auto WebClient service:

sc config webclient start=auto

Run as Admin.

P.S. But I have to admit that my way (walkFileTree) to copy files from WebDAV server may be way far from the optimal.

huangapple
  • 本文由 发表于 2020年9月6日 19:13:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/63763499.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定