mirror of
https://github.com/ZSCGR/CloudFlare-ImgBed.git
synced 2026-08-13 04:03:42 +08:00
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.
This commit is contained in:
@@ -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 `<D:response><D:href>${encodeURI(`/${file.name}`)}</D:href><D:propstat><D:prop><D:displayname>${file.name.split('/').pop()}</D:displayname><D:resourcetype/><D:creationdate>${now}</D:creationdate><D:getlastmodified>${now}</D:getlastmodified><D:getcontentlength>${fileSize}</D:getcontentlength></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response>`;
|
||||
const fileSize = file.metadata && file.metadata['FileSizeBytes'] ? file.metadata['FileSizeBytes'] : "0";
|
||||
return `<D:response><D:href>${encodeURI(`/dav/${file.name}`)}</D:href><D:propstat><D:prop><D:displayname>${file.name.split('/').pop()}</D:displayname><D:resourcetype/><D:creationdate>${now}</D:creationdate><D:getlastmodified>${now}</D:getlastmodified><D:getcontentlength>${fileSize}</D:getcontentlength></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user