cancel
Showing results for 
Search instead for 
Did you mean: 

Copy binary content in Javascript

fedorow
Elite Collaborator
Elite Collaborator

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 ACCEPTED ANSWER

fedorow
Elite Collaborator
Elite Collaborator

sorry, I found method by myself

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

View answer in original post

1 REPLY 1

fedorow
Elite Collaborator
Elite Collaborator

sorry, I found method by myself

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