From c2e4de5b8c68f2e794999bdf3be1be97f09ba24b Mon Sep 17 00:00:00 2001
From: MarSeventh <1193267292@qq.com>
Date: Fri, 1 May 2026 20:36:07 +0800
Subject: [PATCH] fix: PROPFIND returns correct file size and href for WebDAV
clients
- Read FileSizeBytes instead of non-existent File-Size metadata field,
so getcontentlength reports actual bytes instead of always 0
- Add /dav prefix to file href so WebDAV clients can GET files at the
correct path
Fixes files showing as 0B and being unopenable in RaiDrive, Cyberduck,
and Windows mapped drives.
---
functions/dav/[[path]].js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/functions/dav/[[path]].js b/functions/dav/[[path]].js
index e938b790..d2e8bd3f 100644
--- a/functions/dav/[[path]].js
+++ b/functions/dav/[[path]].js
@@ -324,6 +324,6 @@ function createCollectionXml(path) {
function createFileXml(file) {
const now = new Date().toUTCString();
- const fileSize = file.metadata && file.metadata['File-Size'] ? file.metadata['File-Size'] : "0";
- return `${encodeURI(`/${file.name}`)}${file.name.split('/').pop()}${now}${now}${fileSize}HTTP/1.1 200 OK`;
+ const fileSize = file.metadata && file.metadata['FileSizeBytes'] ? file.metadata['FileSizeBytes'] : "0";
+ return `${encodeURI(`/dav/${file.name}`)}${file.name.split('/').pop()}${now}${now}${fileSize}HTTP/1.1 200 OK`;
}