1
用戶可以通過UI上傳EDUPUB/Zip文件。我們希望實現一個REST api擴展模塊來將EDUPUB/Zip文件和攝入到MarkLogic數據庫中。 MarkLogic API API支持這個嗎?有什麼建議麼?是否可以通過Rest API擴展模塊將EDUPUB(如Zip文件)插入到marklogic數據庫中
我實現下面的代碼用於提取和上傳EDUPUB/Zip文件
xquery version "1.0-ml";
declare namespace zip="xdmp:zip";
declare function local:epubupload ($filepath as xs:string)
{
let $get_document :=xdmp:document-get($filepath)
let $get_uri := fn:document-uri($get_document)
let $get_document_uri := fn:concat($get_uri, "/")
let $get_collection := fn:tokenize($get_uri, "\\")[last()]
let $epub_extract := xdmp:zip-manifest($get_document)
for $each_file in $epub_extract/zip:part/text()
let $document_data := xdmp:zip-get($get_document, $each_file)
let $full_document_uri := fn:concat($get_document_uri, $each_file)
return xdmp:document-insert($full_document_uri, $document_data,(), $get_collection)
};
local:epubupload("c:\data\sample.epub")
但對於REST API是什麼參數?以及如何從用戶系統獲取整個文件?
感謝大衛的建議。 – Raj