4
  • 沙丁鱼版:5.8
  • Java 1.8

(与任何依赖项覆盖相关?)

  • Spring Boot 2.1.2 项目
  • Tomcat9.0.14

我可以通过沙丁鱼连接到我的服务器(Nextcloud)。执行的put-call 也会对服务器产生影响,因为它将预期的 File 放入正确的目录中。但如标题所述,该文件为空(0byte)。也没有客户端异常。

使用put(String, byte[])按预期工作,并且服务器上的文件完全正常工作。但我不想被限制在byte[Integer.MAX-5].

以下代码正在运行,这意味着它与 ssl 或任何其他与连接相关的事情无关

File file = new File(filePath);
byte[] data = new byte[(int) file.length()];
FileInputStream stream = new FileInputStream(file);
int readedBytes = stream.read(data);
if (readedBytes == file.length()) {
   client.put(remotePath, data);
}

此代码不起作用

File file = new File(filePath);
client.put(remotePath, new FileInputStream(file));

在 Nextcloud 服务器上,我得到以下日志条目:

"Exception":"Sabre\\DAV\\Exception\\BadRequest","Message":"expected filesize 240823 got 0"

对我来说,将输入流内容复制到实际的 http 输出流时似乎出了点问题。正如我们在服务器日志中看到的那样,标头似乎具有正确的字节大小,但实际内容为零。

其他人有这个问题吗?我错过了什么吗?感谢您的任何提示和帮助!

4

0 回答 0