cancel
Showing results for 
Search instead for 
Did you mean: 

I need to send a document of a Software for Alfresco

viperboys
Star Contributor
Star Contributor

Hi,
I need to send a document of a Software for Alfresco. I am using this service http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-shared-/children for create a document but i need send a file. For example: Send a PDF document to Alfresco.

What service can I consume for this?

Thank you

1 ACCEPTED ANSWER

EddieMay
World-Class Innovator
World-Class Innovator

Hi @viperboys,

I've just used Postman to upload two documents to my home  directory in Alfresco.

Here is the generated PHP code from Postman:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Documents/Alfresco - a developer led strategy.pptx')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Attached you can see the files in Share.

Here's the code for uploading a jpg file:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Downloads/eddie.may.jpg')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Hopefully this should give you a start to resolving your problem.

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

View answer in original post

16 REPLIES 16

Hi @EddieMay 
Thanks for your valuable help. Yesterday I tried to do the same but I have this error.

{
    "exception""invalidArgument",
    "message""Invalid form encoding!"
}
I am doing these tests with Postman
URL: http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/root?objectId=45a0643c... SurprisedbjectTypeId&propertyValue[1]=cmis:document&alf_ticket=TICKET_bd5a46d1fcf87aca154220f959d19d141abc0903

Method POST

EddieMay
World-Class Innovator
World-Class Innovator

Hi @viperboys,

I've just used Postman to upload two documents to my home  directory in Alfresco.

Here is the generated PHP code from Postman:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Documents/Alfresco - a developer led strategy.pptx')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Attached you can see the files in Share.

Here's the code for uploading a jpg file:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?alf_ticket=TICKET_53451c24e8042867a93f0d129bbd3b1f5e2a5a55",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('filedata'=> new CURLFILE('/Users/emay/Downloads/eddie.may.jpg')),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic dGVzdDp0ZXN0"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Hopefully this should give you a start to resolving your problem.

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

Hi @EddieMay 

I am very grateful for your help. I am a little confused, this is because I am new to this area.

That php code was generated by Postman? How can I use it with postman? I have always used a URL, the method and send a JSON. This is how it worked for me but what you send me I don't know how to put it in Postman.

I hope you can help me. Thank you very much and happy day.

EddieMay
World-Class Innovator
World-Class Innovator

Hi @viperboys,

Don't worry - we were all new to this at one time. Some of us (like me) still are!! 

The code I shared was acutally generated by Postman. The app has a "generate code" option - you can select the language & et voila! There are several languages available, including javascript such as Node. On my Mac the code button is to the right, below the Send button (see attached)

I'm thinking you can perhaps incorporate the url call & data into yourGravityFlow plugin WebHook.

HTH,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

Hi @EddieMay 

Now it worked. Thank you very much for your valuable help.

God bless you.