03-23-2020 02:35 PM
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
03-26-2020 12:55 PM
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.
03-25-2020 02:37 PM
Hi @EddieMay
Thanks for your valuable help. Yesterday I tried to do the same but I have this error.
03-26-2020 12:55 PM
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.
03-27-2020 09:59 AM
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.
03-27-2020 10:24 AM
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,
03-27-2020 11:26 AM
03-27-2020 12:28 PM
Hi @viperboys,
Great news & happy to help. Have a great weekend!
03-27-2020 10:28 AM
Hi @viperboys ,
In Postman I'd recommend getting the call to work - this will prove the concept that you can post a file to Alfresco using the Alfresco API.
Then in Postman you could begin to override the body of your working method to use JSON to include the file, authentication, etc. If you click on the body section and select Raw, you have json as an option (see attached).
HTH
Explore our Alfresco products with the links below. Use labels to filter content by product module.