<?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 Copy binary content in Javascript in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/copy-binary-content-in-javascript/m-p/148467#M39245</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I must create a new document (doc) with first version from source document. The source document have several versions. New doc must have only one version with content from source. Content is PDF.&lt;/P&gt;&lt;P&gt;Next Javascrip code create a doc, but as expected binary content copyes as string.&lt;/P&gt;&lt;PRE&gt;var versionHistory = document.getVersionHistory();&amp;nbsp;&lt;BR /&gt;var workFolder = companyhome.childByNamePath("Sites/swsdp/documentLibrary/test");
var doc = workFolder.createFile("new_copy_1.pdf");
doc.addAspect('cm:versionable');
doc.content = versionHistory[versionHistory.length-1].getNode().content;
doc.save();&lt;/PRE&gt;&lt;P&gt;How to copy binary content in Javascript?&lt;/P&gt;&lt;P&gt;Thanks for your help, peace,&lt;/P&gt;&lt;P&gt;Serge&lt;/P&gt;</description>
    <pubDate>Sun, 04 Jun 2023 22:49:00 GMT</pubDate>
    <dc:creator>fedorow</dc:creator>
    <dc:date>2023-06-04T22:49:00Z</dc:date>
    <item>
      <title>Copy binary content in Javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/copy-binary-content-in-javascript/m-p/148467#M39245</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I must create a new document (doc) with first version from source document. The source document have several versions. New doc must have only one version with content from source. Content is PDF.&lt;/P&gt;&lt;P&gt;Next Javascrip code create a doc, but as expected binary content copyes as string.&lt;/P&gt;&lt;PRE&gt;var versionHistory = document.getVersionHistory();&amp;nbsp;&lt;BR /&gt;var workFolder = companyhome.childByNamePath("Sites/swsdp/documentLibrary/test");
var doc = workFolder.createFile("new_copy_1.pdf");
doc.addAspect('cm:versionable');
doc.content = versionHistory[versionHistory.length-1].getNode().content;
doc.save();&lt;/PRE&gt;&lt;P&gt;How to copy binary content in Javascript?&lt;/P&gt;&lt;P&gt;Thanks for your help, peace,&lt;/P&gt;&lt;P&gt;Serge&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2023 22:49:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/copy-binary-content-in-javascript/m-p/148467#M39245</guid>
      <dc:creator>fedorow</dc:creator>
      <dc:date>2023-06-04T22:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Copy binary content in Javascript</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/copy-binary-content-in-javascript/m-p/148468#M39246</link>
      <description>&lt;P&gt;sorry, I found method by myself&lt;/P&gt;&lt;PRE&gt;doc.properties.content.write(history[history.length-1].getNode().properties.content);&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Jun 2023 23:04:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/copy-binary-content-in-javascript/m-p/148468#M39246</guid>
      <dc:creator>fedorow</dc:creator>
      <dc:date>2023-06-04T23:04:45Z</dc:date>
    </item>
  </channel>
</rss>

