使用 xquery 存储文件存在
Storing files with xquery in exist
运行 直接在 eXide (Eval) 中使用以下 xquery 它工作正常,将 MyFSdirectory 中的 XML 文件添加到 MyCollectionPath 中:
xquery version "3.1";
let $selected_directory:= 'MyFSdirectory'
let $source-directory := $selected_directory
let $target-collection := 'MyCollectionPath'
return
xmldb:store-files-from-pattern($target-collection, $source-directory, '*.xml')
但是当我将它添加到一个函数并从我的应用程序调用它时,store-files-from-pattern 没有完成这项工作(没有显示错误但没有上传文件),打印了检查点在我的屏幕上,所以函数被正确调用。有什么提示吗?
declare function app:upload_file($node as node(), $model as map(*)) {
let $selected_directory:= "MyFSdirectory"
let $source-directory := $selected_directory
let $target-collection := "MyCollectionPath"
return
<p>check point</p> |
xmldb:store-files-from-pattern($target-collection, $source-directory, '*.xml')
};
这听起来像是权限问题。换句话说,当您 运行 eXide 中的脚本时,您很可能 运行 宁作为用户(例如 "admin")对目标集合具有写权限,但在您的应用程序中该脚本很可能 运行宁作为来宾用户而没有写入目标集合所需的权限。
要排除故障,请将调用 xmldb:login()
的表达式添加到您的 app:upload_file()
函数,为您在 eXide 中使用的用户提供凭据。
如果以这种方式提升权限有效,那么下一步将考虑在目标集合上设置适当的权限,或者在写入数据库的模块上设置应用 setuid or setgid。
运行 直接在 eXide (Eval) 中使用以下 xquery 它工作正常,将 MyFSdirectory 中的 XML 文件添加到 MyCollectionPath 中:
xquery version "3.1";
let $selected_directory:= 'MyFSdirectory'
let $source-directory := $selected_directory
let $target-collection := 'MyCollectionPath'
return
xmldb:store-files-from-pattern($target-collection, $source-directory, '*.xml')
但是当我将它添加到一个函数并从我的应用程序调用它时,store-files-from-pattern 没有完成这项工作(没有显示错误但没有上传文件),打印了检查点在我的屏幕上,所以函数被正确调用。有什么提示吗?
declare function app:upload_file($node as node(), $model as map(*)) {
let $selected_directory:= "MyFSdirectory"
let $source-directory := $selected_directory
let $target-collection := "MyCollectionPath"
return
<p>check point</p> |
xmldb:store-files-from-pattern($target-collection, $source-directory, '*.xml')
};
这听起来像是权限问题。换句话说,当您 运行 eXide 中的脚本时,您很可能 运行 宁作为用户(例如 "admin")对目标集合具有写权限,但在您的应用程序中该脚本很可能 运行宁作为来宾用户而没有写入目标集合所需的权限。
要排除故障,请将调用 xmldb:login()
的表达式添加到您的 app:upload_file()
函数,为您在 eXide 中使用的用户提供凭据。
如果以这种方式提升权限有效,那么下一步将考虑在目标集合上设置适当的权限,或者在写入数据库的模块上设置应用 setuid or setgid。