Copy binary content in Javascript

cancel
Showing results for 
Search instead for 
Did you mean: 
fedorow
Senior Member II

Copy binary content in Javascript

Jump to solution

Hi!

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.

Next Javascrip code create a doc, but as expected binary content copyes as string.

 

var versionHistory = document.getVersionHistory(); 
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();

 

 

How to copy binary content in Javascript?

 

Thanks for your help, peace,

Serge

1 Solution

Accepted Solutions
fedorow
Senior Member II

Re: Copy binary content in Javascript

Jump to solution

sorry, I found method by myself

doc.properties.content.write(history[history.length-1].getNode().properties.content);

View solution in original post

1 Reply
fedorow
Senior Member II

Re: Copy binary content in Javascript

Jump to solution

sorry, I found method by myself

doc.properties.content.write(history[history.length-1].getNode().properties.content);