node.js - 在 webdav 客户端中请求自定义字段
问题描述
我尝试了许多不同的方法来读取带有自定义详细信息的 nextCloud api 目录,例如:
'<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop xmlns:oc="http://owncloud.org/ns">
<d:getlastmodified/>
<d:getcontentlength/>
<d:getcontenttype/>
<oc:permissions/>
<d:resourcetype/>
<oc:share-types />
<oc:fileid />
<d:getetag/>
</d:prop>
</d:propfind>'
首先,我尝试使用 child_process 运行 curl 命令,例如:
var command = `curl -u username:password 'https://cloud.example.com/remote.php/dav/files/username/folder' -X PROPFIND --data '<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop xmlns:oc="http://owncloud.org/ns">
<d:getlastmodified/>
<d:getcontentlength/>
<d:getcontenttype/>
<oc:permissions/>
<d:resourcetype/>
<d:getetag/>
</d:prop>
</d:propfind>'`
import { exec } from "child_process"
const child = exec(command, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
return stdout;
});
当我运行它时,我收到了这个错误消息,它没有说明它有什么问题
error: Command failed: curl -u username:password 'https://cloud.example.com/remote.php/dav/files/username/folder' -X PROPFIND --data '<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop xmlns:oc="http://owncloud.org/ns">
<d:getlastmodified/>
<d:getcontentlength/>
<d:getcontenttype/>
<oc:permissions/>
<d:resourcetype/>
<d:getetag/>
</d:prop>
</d:propfind>'
但是,当我复制错误消息在另一个终端实例上返回的相同 curl 命令时,我在控制台上打印了正确的 xml 文件。我真的很困惑为什么会这样?另外,我想将标准输出保存到 xml 变量中以供以后使用?我怎样才能做到这一点?我被这个问题困扰了好几个小时,我似乎无法弄清楚。谢谢你的帮助!
解决方案
推荐阅读
- r - 加快data.table的子集化和数千次回归的实现
- javascript - 使用 JavaScript 将文件夹上传到服务器
- c++ - 将函数作为参数传递。C++
- azure - 联接查询 cosmos DB 中的两个文档
- javascript - 通过登录“隐藏”安全漏洞的旧javascript库?
- reactjs - 开玩笑 - 找不到模块 ./fonts/galio.ttf 映射为
- python - PlotCurveItem 和 SetLogMode 的问题
- fix-protocol - Quickfix破解如何实现OnMessage(ResendRequest)?
- javascript - nodemon 应用程序崩溃 - 在启动之前等待文件更改?
- angular - 如何防止用户登录后返回登录页面