【问题标题】:Is it possible to use xdmp:save with REST?是否可以将 xdmp:save 与 REST 一起使用?
【发布时间】:2018-03-22 01:48:57
【问题描述】:

我正在尝试将大型文档从 MarkLogic 数据库复制到文件系统。我想用 REST 和 xdmp:save 来做。但是,我无法找到有关如何执行此操作的任何信息。这是我所拥有的:

curl -s --anyauth --user admin:admin -X GET -i -d "xdmp:save('/my/workspace/uris/LargeDoc.xml', fn:doc('/Collection/SomeDatabase/LargeDoc.xml'))" -H "Content-type: application/x-www-form-urlencoded" -H "Accept: multipart/mixed; boundary=BOUNDARY" "http://localhost:8000/v1/eval?database=SomeDatabase"

这可能吗? 我可以在 qconsole 中选择正确的数据库来执行xdmp:save('/my/workspace/uris/LargeDoc.xml', fn:doc('/Collection/SomeDatabase/LargeDoc.xml'))。但是,我想创建一个脚本或工具来完成这项任务。

【问题讨论】:

  • 是的,有可能。你有什么问题?请记住,xdmp:save 告诉 服务器 将文件保存到其文件系统上的路径。如果您想将文件下载到调用脚本的客户端,请使用http://localhost:8000/v1/documents?uri=/Collection/SomeDatabase/LargeDoc.xml&database=SomeDatabase 检索它并将响应保存到您想要的任何位置。

标签: rest curl xquery marklogic marklogic-8


【解决方案1】:

如果您希望使用 REST API 下载文档,请从 /v1/documents (GET) 端点请求。

例如,使用 curl,您可以使用 -o 选项将响应保存到本地文件:

curl --anyauth --user admin:admin -X GET --create-dirs 
  -o /Collection/SomeDatabase/LargeDoc.xml 
  "http://localhost:8000/v1/documents?uri=/Collection/SomeDatabase/LargeDoc.xml&database=SomeDatabase"

【讨论】:

    猜你喜欢
    • 2011-06-13
    • 2015-12-28
    • 1970-01-01
    • 2021-11-12
    • 2016-04-01
    • 2011-01-20
    • 2018-08-11
    • 2021-08-05
    • 2019-03-18
    相关资源
    最近更新 更多