Create directories if not exist Nuxeo

I am attempting to do a document.copy on an existing document, with the assumption that if the directories I am copying into may or may not exist. What would be a good way to achieve that?

 client = new nuxeo.Client(nuxeoParams)
 client.connect()
 copyOp = client.operation("Document.Copy")
 path = "doc:#{devConfig.path}#{devConfig.username}/#{devConfig.env}"/file.title
 var copyParams =
      { target: "doc:#{devConfig.path}#{devConfig.username}/#{devConfig.env}/documents/#{documentId}/" }
 copyOp.input(path).params(copyParams)
 copyOp.execute(function(error, data){
 if(error){
    console.debug('error')
 }else{
    console.debug('data')
 }
})

This 404s. What would be a way to avoid this and create the directories necessary in a lazy manner?

1 votes

1 answers

1748 views

ANSWER



I ended up catching the 404s and creating the directories as needed. It was pretty verbose, so I'd welcome anyone showing a better way.

0 votes