09-14-2016 10:27 AM
I know this question has been asked before and was even a subject of a blog article, but answers to those were focused on curl like URLs and not so much on input/output variables. So:
With Blob.Get one can get either the main-document or a document attached to a main-document depending on the parameters being passed. General layout would be (in PHP, but more or less generic):
->newRequest("Blob.Get") ->set('input', 'doc:'' . $idoc) ->set('input', 'docs:" . $idocs) ->set('param', 'xpath', $xpath)
docs and xpath are optional
Depending on what you provide one can get returned:
So far I failed to get an attachment using the rest API. As the 'data' property contains the full URL it can be done using curl or the likes. But how to commence using the REST API itself (call returning a blob as can be expected of blob.get)? docs:utl from data? xpath:files:content[no-of-attachment] or ... ?
Is this documented with examples somewhere?
09-28-2016 06:44 AM
Hi olaf, As explained in the Nuxeo Automation Commands doc, the Blob.Get operation need documents as input and accept an XPath to a property. The documents input are explained in the Nuxeo Command Endpoint doc:
"
doc:/default-domain/workspaces/myworkspace
" or "doc:96bfb9cb-a13d-48a2-9bbd-9341fcf24801
"
"
docs:/default-domain/workspaces/myworkspace, 96bfb9cb-a13d-48a2-9bbd-9341fcf24801
"
Although your XPath is correct with files:files/1/file
, what you can find with the JSON/XML export of your main document.
Note that the current version of the PHP Automation Client creates as tempstream
file when using the Blob.Get
operation (a rewrite of the client is under way), you can find an example in the sample B5 in the sources of the client.
With the previous data, you should be able to make a running code as the following :
function GetBlob($path = '/default-domain/workspaces/Default Workspace/Some note') {
$client = new \Nuxeo\Automation\Client\NuxeoPhpAutomationClient('http://nuxeo:8080/nuxeo/site/automation');
$session = $client->getSession('Administrator', 'Administrator');
$answer = $session->newRequest("Blob.Get")->set('input', 'doc:' . $path)->set('params', 'xpath', 'files:files/0/file')->sendRequest();
if (!isset($answer) OR $answer == false)
echo '$answer is not set';
else {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=image.png');
readfile('tempstream');
}
}
09-14-2016 11:36 AM
For the sake of completeness
09-20-2016 10:54 AM
Probably the closest thing to documentation on the subject is
09-28-2016 06:44 AM
Hi olaf, As explained in the Nuxeo Automation Commands doc, the Blob.Get operation need documents as input and accept an XPath to a property. The documents input are explained in the Nuxeo Command Endpoint doc:
"
doc:/default-domain/workspaces/myworkspace
" or "doc:96bfb9cb-a13d-48a2-9bbd-9341fcf24801
"
"
docs:/default-domain/workspaces/myworkspace, 96bfb9cb-a13d-48a2-9bbd-9341fcf24801
"
Although your XPath is correct with files:files/1/file
, what you can find with the JSON/XML export of your main document.
Note that the current version of the PHP Automation Client creates as tempstream
file when using the Blob.Get
operation (a rewrite of the client is under way), you can find an example in the sample B5 in the sources of the client.
With the previous data, you should be able to make a running code as the following :
function GetBlob($path = '/default-domain/workspaces/Default Workspace/Some note') {
$client = new \Nuxeo\Automation\Client\NuxeoPhpAutomationClient('http://nuxeo:8080/nuxeo/site/automation');
$session = $client->getSession('Administrator', 'Administrator');
$answer = $session->newRequest("Blob.Get")->set('input', 'doc:' . $path)->set('params', 'xpath', 'files:files/0/file')->sendRequest();
if (!isset($answer) OR $answer == false)
echo '$answer is not set';
else {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=image.png');
readfile('tempstream');
}
}
09-30-2016 11:11 AM
Thank you Pierre-Gildas Millon. When creating this new client could you please consider using http
10-17-2016 08:29 AM
The present version is an Automation API client, is does not implement the full Rest API of Nuxeo.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.