11-16-2016 11:39 AM
Hi, I have a problem, I can upload a file with normal metadata, but I have a subtype of metadata like this:
<xs:complexType name="blobList">
<xs:sequence>
<xs:element name="item" type="nxs:content" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
/>
<xs:element name="field1" type="xs:string"/>
<xs:element name="field2" type="xs:date"/>
<xs:element name="example1" type="nxs:exampleListType"/>
<xs:complexType name="exampleListType">
<xs:sequence>
<xs:element name="item" type="nxs:exampleListType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="nxs:exampleListType">
<xs:sequence>
<xs:element name="field_01" type="xs:string"/>
<xs:element name="field_02" type="xs:string"/>
<xs:element name="field_03" type="xs:string"/>
<xs:element name="field_04" type="xs:string"/>
<xs:element name="field_05" type="xs:string"/>
</xs:sequence>
</xs:complexType>
and I trying to upload a file adding metadata like this:
$answer= $session->newRequest("Document.Create")
->set('input', 'doc:' . $array1['PATH'])
->set('params', 'type', 'example_doc')
->set('params', 'name', $array2['name'])
->sendRequest();
$ls_path = $answer->getDocument(0)->getPath();
$ls_UID = $answer->getDocument(0)->getUid();
$answer= $session->newRequest("Document.SetProperty")
->set('input', 'doc:' . $ls_path)
->set('params', 'value', $array2['name'])
->set('params', 'xpath', 'dc:title')
->sendRequest();
how can I do for upload a file to nuxeo with subtype and his properties? thanks
11-17-2016 05:03 PM
Hi, You should be able to create your document with metadata and then attach a file with the following code:
$answer = $session
->newRequest('Document.Create')
->set('input', 'doc:/default-domain/workspaces/Default Workspace')
->set('params', 'type', 'Article')
->set('params', 'name', 'doc01')
->set('params', 'properties', 'dc:title=doc01
article:exampleList=[{"field01":"val001","field02":"val002","field03":"val003"}]')
->sendRequest();
$answer = $session
->newRequest('Blob.Attach')
->set('params', 'document', $answer->getDocument(0)->getPath())
->loadBlob('test.txt', 'text/plain')
->sendRequest();
Some references:
http://explorer.nuxeo.com/nuxeo/site/distribution/Nuxeo%20DM-8.3/viewOperation/Document.Create
11-16-2016 05:21 PM
You should try the "Blob.Attach" operation. For instance like this:
$answer= $session->newRequest("Document.Create")
->set('input', 'doc:' . $array1['PATH'])
->set('params', 'type', 'example_doc')
->set('params', 'name', $array2['name'])
->sendRequest();
$ls_path = $answer->getDocument(0)->getPath();
$ls_UID = $answer->getDocument(0)->getUid();
$ls_doc = $answer->getDocument(0);
$answer= $session->newRequest("Document.SetProperty")
->set('input', 'doc:' . $ls_path)
->set('params', 'value', $array2['name'])
->set('params', 'xpath', 'dc:title')
->sendRequest();
//We upload the file
$result = $session->newRequest("Blob.Attach")
->set('params', 'document', $ls_doc->getPath())
->loadBlob($FilePath, $FileMimotype)
->sendRequest();
where:
11-17-2016 07:27 AM
I answered up this post
11-17-2016 07:27 AM
Thanks for the answer. I explained it wrong, I can upload the file but I can't set some metadata. For example: I can set typical metada like creator etc, but I can't set metadata which containing a list or type which more fields.
With this code I can set normal metadata and it works:
$answer= $session->newRequest("Document.SetProperty")
->set('input', 'doc:' . $ls_path)
->set('params', 'value', $array2['name'])
->set('params', 'xpath', 'dc:title')
->sendRequest();
But I don't know how can I insert a metadata which contains other fields of metadata like xml I put at first post. I can't do screenshot now, but for example If I have a file that represents a book in nuxeo, and this book has many authors, I have a complexType called author with his fields like name, gender etc. How I can set this fields?
11-17-2016 01:34 PM
Have you try the 'AddEntryToMultivaluedProperty' operation:
foreach ($array2 as $item)
{
$answer= $session->newRequest("AddEntryToMultivaluedProperty")
->set('input', 'doc:' . $ls_path)
->set('params', 'value', $item)
->set('params', 'xpath', 'Your:list_parameter')
->sendRequest();
}
or the 'Document.AddItemToListProperty' operation?
11-17-2016 05:03 PM
Hi, You should be able to create your document with metadata and then attach a file with the following code:
$answer = $session
->newRequest('Document.Create')
->set('input', 'doc:/default-domain/workspaces/Default Workspace')
->set('params', 'type', 'Article')
->set('params', 'name', 'doc01')
->set('params', 'properties', 'dc:title=doc01
article:exampleList=[{"field01":"val001","field02":"val002","field03":"val003"}]')
->sendRequest();
$answer = $session
->newRequest('Blob.Attach')
->set('params', 'document', $answer->getDocument(0)->getPath())
->loadBlob('test.txt', 'text/plain')
->sendRequest();
Some references:
http://explorer.nuxeo.com/nuxeo/site/distribution/Nuxeo%20DM-8.3/viewOperation/Document.Create
11-21-2016 06:45 AM
Its Works! Thank you so much!
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.