<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic create document with multiple files using java api in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/create-document-with-multiple-files-using-java-api/m-p/315188#M2189</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to use the java api to create a document with attached files.&lt;/P&gt;
&lt;P&gt;I saw the examples in the documentation and it's working fine.&lt;/P&gt;
&lt;P&gt;Now I want to try my &lt;STRONG&gt;own method&lt;/STRONG&gt; : one call to create the document and attach the files &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Set&amp;lt;BlobDTO&amp;gt; blobs = dto.getBlobs();
if (blobs != null &amp;amp;&amp;amp; !blobs.isEmpty()) {
	List&amp;lt;Map&amp;lt;String, Map&amp;lt;String, Object&amp;gt;&amp;gt;&amp;gt; files = new ArrayList&amp;lt;&amp;gt;();
	for (BlobDTO blob : blobs) {
		Map&amp;lt;String, Object&amp;gt; content = new HashMap&amp;lt;&amp;gt;();
		content.put("mime-type", blob.getMimeType());
		content.put("length", blob.getContentLength());
		content.put("name", blob.getFilename());
		content.put("data", Base64.getEncoder().encodeToString(IOUtils.toByteArray(blob.getInputStream())));
		
		Map&amp;lt;String, Map&amp;lt;String, Object&amp;gt;&amp;gt; file = new HashMap&amp;lt;&amp;gt;();
		file.put("file", content);
		files.add(file);
	}
	document.setPropertyValue("files:files", files);
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The document is created in Nuxeo, and the files are attached, but it's juste text files with the "data" inside, not the good files !&lt;/P&gt;
&lt;P&gt;Can you please tell me why It's not working ?&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 18:39:35 GMT</pubDate>
    <dc:creator>Ghazi_HAKIM</dc:creator>
    <dc:date>2020-03-11T18:39:35Z</dc:date>
    <item>
      <title>create document with multiple files using java api</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/create-document-with-multiple-files-using-java-api/m-p/315188#M2189</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to use the java api to create a document with attached files.&lt;/P&gt;
&lt;P&gt;I saw the examples in the documentation and it's working fine.&lt;/P&gt;
&lt;P&gt;Now I want to try my &lt;STRONG&gt;own method&lt;/STRONG&gt; : one call to create the document and attach the files &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Set&amp;lt;BlobDTO&amp;gt; blobs = dto.getBlobs();
if (blobs != null &amp;amp;&amp;amp; !blobs.isEmpty()) {
	List&amp;lt;Map&amp;lt;String, Map&amp;lt;String, Object&amp;gt;&amp;gt;&amp;gt; files = new ArrayList&amp;lt;&amp;gt;();
	for (BlobDTO blob : blobs) {
		Map&amp;lt;String, Object&amp;gt; content = new HashMap&amp;lt;&amp;gt;();
		content.put("mime-type", blob.getMimeType());
		content.put("length", blob.getContentLength());
		content.put("name", blob.getFilename());
		content.put("data", Base64.getEncoder().encodeToString(IOUtils.toByteArray(blob.getInputStream())));
		
		Map&amp;lt;String, Map&amp;lt;String, Object&amp;gt;&amp;gt; file = new HashMap&amp;lt;&amp;gt;();
		file.put("file", content);
		files.add(file);
	}
	document.setPropertyValue("files:files", files);
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The document is created in Nuxeo, and the files are attached, but it's juste text files with the "data" inside, not the good files !&lt;/P&gt;
&lt;P&gt;Can you please tell me why It's not working ?&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 18:39:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/create-document-with-multiple-files-using-java-api/m-p/315188#M2189</guid>
      <dc:creator>Ghazi_HAKIM</dc:creator>
      <dc:date>2020-03-11T18:39:35Z</dc:date>
    </item>
  </channel>
</rss>

