08-08-2018 07:43 AM
How to upload file in Alfresco via API?
Currently I am using 'cmis_repository_wrapper' class (please see attachment ) but not able to find related API for file upload?
Could you please guide me where I can get Alfresco API for file upload in PHP?
It would be good if you can share any example with it.
Thanks,
Sunil
08-09-2018 09:46 AM
Hi Sunil,
You can use the below github url for You can find a reference implementation in PHP using CMIS api
https://github.com/donbalon4/API_Alfresco
08-14-2018 02:07 AM
Hi Ranjeet,
Thanks for your reply. I have looked into given GIT repo and found that it is using 'uploadFile' function but not able to get where I can give destination path (Workspace path).
I need to upload file into Alfresco workspace (in particular folder) . Just like we are uploading file into Alfresco after logged in into the Alfresco sysytem. Same thing I need to do via API so I don't need to login in to Alfresco server.
Please let me know that if you have any question. Could you please reply on this question asap.
08-14-2018 09:03 PM
I have not tried using "cmis_repository_wrapper" but have generated a fresh code without that - check below
https://community.alfresco.com/servlet/JiveServlet/downloadBody/7997-102-1-14122/php_upload.docx
=================================
PHP HttpRequest:
<?php
$request = new HttpRequest();
$request->setUrl('http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'objectId' => 'd140f140-2701-4ca6-8a80-8cdc9cd3b72c',
'cmisaction' => 'createDocument',
'propertyId[0]' => 'cmis:name',
'propertyValue[0]' => 'ThirdPartyFormApigee.jpg',
'propertyId[1]' => 'cmisbjectTypeId',
'propertyValue[1]' => 'cmis:document',
'alf_ticket' => 'TICKET_3375c54fb50e6251d9e57f696483708ff9cc653a'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
));
$request->setBody('------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name=""; filename="Penguins.jpg"
Content-Type: image/jpeg
------WebKitFormBoundary7MA4YWxkTrZu0gW--');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
============================
Please let me know if it helps.
08-15-2018 05:15 AM
Also check for the url
postObject method
Explore our Alfresco products with the links below. Use labels to filter content by product module.