Hello, Whenever I make call to
http://marklogic.mycompany.com:9042/v1/resources/resize?rs:width=300&rs:height=300&rs:uri=/2014/11/20/IC20141120.jpg I get this error message : <rapi:error xmlns:rapi="http://marklogic.com/rest-api"><rapi:status-code>500 </rapi:status-code><rapi:status>INTERNAL ERROR</rapi:status>< rapi:message-code>XDMP-UPDATEFUNCTIONFROMQUERY</rapi:message-code>< rapi:message>XDMP-UPDATEFUNCTIONFROMQUERY: Q{ http://marklogic.com/rest-api/resource/resize}get#2($context, $service-params) -- Cannot apply an update function from a query. See the MarkLogic server error log for further detail.</rapi:message></rapi:error> I know this happens because of the xdmp:document-insert() call inside the code for that API call. My question is, is there a workaround for this ? I already tried wrapping the document-insert call with xdmp:spawn-function, but that didn't work either. Below is the code. Regards, Danny ======================================================================================= *xquery version *"1.0-ml"; *module namespace **local* = "http://marklogic.com/rest-api/resource/resize" ; *declare option **xdmp:update* "true"; *declare function **local:get*(*$context* *as **map:map*, *$params* *as * *map:map*) *as **document-node*()* { *let **$image_server_root* := " http://solrdev1.mycompany.com:7000/resize_image" *let* *$uri* := *map:get*(*$params*,"uri") *let* *$width* := *map:get*(*$params*,"width") *let* *$height* := *map:get*(*$params*,"height") *let* *$resized_uri* := *fn:concat*(*fn:substring-before*(*$uri*, ".jpg"),"_",*$width*,"_",*$height*,".jpg") *let* *$resized_image* := *if* (*xdmp:uri-is-file*(*$resized_uri*)) *then * *fn:doc*(*$resized_uri*) *else * *let **$image* := *fn:doc*(*$uri*)/*node*() *let* *$image_name* := *fn:tokenize*(*$uri*,"/")[*last*()] *let* *$temp_image* := *xdmp:http-put*(*fn:concat*(*$image_server_root*, "/",*$width*,"/",*$height*,"/",*$image_name*,"?resized_uri=",*$resized_uri*), (), *$image*)[2] *let* *$_* := *xdmp:spawn-function*(*function*() { *xdmp:document-insert* ("/2014/11/20/danny.jpg", *$temp_image*, *xdmp:default-permissions*()) }) *return * *$temp_image* *let* *$mime_type* := *map:put*(*$context*,"output-types","image/jpeg") *return document*{*$resized_image*} };
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
