cancel
Showing results for 
Search instead for 
Did you mean: 

Apache CMIS PHP versioning

madelarra
Champ in-the-making
Champ in-the-making
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.
1 REPLY 1

gmasand09
Confirmed Champ
Confirmed Champ

Could You please explain me this example. I am doing the same but stuck while connecting dont know how to connect could you please explain me the steps.