We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.

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

We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.

Jump to solution

We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.Could you kindly suggest?

i tried crossRepoCopy function, but it is not letting me copy version files to this particular folder

1 Solution

Accepted Solutions
mehe
Senior Member II

Re: We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.

Jump to solution

I slightly remember a problem copying between stores way back in time. Since the "versions" of a document are stored in the "versionstore" your problem could be the same. Assuming you have an element v of a nodes node.versionHistory, your srcNode would be v.getNode() and targetFileName would be srcNode.name...

function copyAcrossStores(srcNode, targetFolderNode, targetFileName) {
            var targetFileNode=targetFolderNode.createFile(targetFileName);
            if (targetFileNode != null) {   
                        //Alfresco 3: get content from source
                        targetFileNode.mimetype=srcNode.mimetype;
                        targetFileNode.content="emptyFile";
                        targetFileNode.save();
                        targetFileNode.properties.content.write(srcNode.properties.content);
            }         
            return targetFileNode;
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Maybe this snippet helps...

View solution in original post

2 Replies
mehe
Senior Member II

Re: We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.

Jump to solution

I slightly remember a problem copying between stores way back in time. Since the "versions" of a document are stored in the "versionstore" your problem could be the same. Assuming you have an element v of a nodes node.versionHistory, your srcNode would be v.getNode() and targetFileName would be srcNode.name...

function copyAcrossStores(srcNode, targetFolderNode, targetFileName) {
            var targetFileNode=targetFolderNode.createFile(targetFileName);
            if (targetFileNode != null) {   
                        //Alfresco 3: get content from source
                        targetFileNode.mimetype=srcNode.mimetype;
                        targetFileNode.content="emptyFile";
                        targetFileNode.save();
                        targetFileNode.properties.content.write(srcNode.properties.content);
            }         
            return targetFileNode;
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Maybe this snippet helps...

jindalnitin20
Member II

Re: We are using Alfresco 3.4.2. I need to copy version documents to specific folder using webscript/API.

Jump to solution

Thanks ..its working