AnsweredAssumed Answered

Apache CMIS PHP versioning

Question asked by madelarra on Apr 18, 2016
Latest reply on Jul 6, 2017 by gmasand09
Hi,

I'm using the Apache Chemistry CMIS PHP client to upload documents from a local folder to Alfresco. Here's the PHP code I'm currently using:

<php>
require_once ('cmis_repository_wrapper.php');
require_once ('cmis_service.php');

$repo_url = "http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom";
$repo_username = "user";
$repo_password = "pass";

$client = new CMISService($repo_url, $repo_username, $repo_password);

$repo_folder = "/alfrescoFolder";
$source_folder = "localFolder/";
$source_files = array_diff(scandir("$source_folder", 1), array('..', '.'));
$myfolder = $client->getObjectByPath($repo_folder);

foreach($source_files as $file)
{
    try
    {
        $upload = $client->createDocumentFromSource($myfolder->id, $file, "$source_folder/$file");
    }
    catch(Exception $e)
    {
        echo "Error";
    }
}
</php>

This script works fine and documents are uploaded without problem, however, I don't know how to create versions of existing documents. For example, let's say I have a document in my Alfresco repository named "example.txt". Well, if I try to upload a document from my local folder with the same name, I get an error. I want to be able to specify that the document I'm uploading is a new version of an existing document. Does anyone know how I can do that? Any help will be appreciated.

Thanks.

Outcomes