cancel
Showing results for 
Search instead for 
Did you mean: 

Example of RESTful upload using curl please.

billmce
Champ in-the-making
Champ in-the-making
This forum would really benefit from a generic example of "how to" upload a file using the command line utility curl.

I can figure out the rest if I can see what's required … and I don't have time to learn JAVA to accomplish this (our project is PHP).
From searching this forum it's clear that I'm not the only one who'd find this useful as a learning and debugging technique.

So, using curl (command line, not php) how would one use the POST to upload a file to the repository using one of the sample webscripts for uploading?

Thanks in advance.

I am having some success, I can upload using one method, it's just not working exactly like I want it.
4 REPLIES 4

faisal
Champ in-the-making
Champ in-the-making
There are some examples of curl with post in jeff pots CMIS examples did you already have a look at those?

In case if you haven't

here is the link.

http://ecmarchitect.com/archives/2009/04/10/959

billmce
Champ in-the-making
Champ in-the-making
Yes, I've struggled through Jeff Potts examples (and I have his book also).
I end up with formdata not defined errors.

If you're familiar with Jeff Potts book, he creates an upload script at about page 261.

Since my application already knows the file that it wants to upload into the repository I need to skip the GET and go directly to the PUT.   I can't work-out how to do this.

I see numerous similar unanswered questions dealing with "formdata is not defined".  I think it's a very common problem.

Thanks in advance

louise
Champ in-the-making
Champ in-the-making
Please check my Curl based shell script to upload content to Alfresco repository: http://louise.hu/poet/?p=4529 (works with HTTP and HTTPS connections too)

dnallsopp
Champ in-the-making
Champ in-the-making
Simple example, tested against Alfresco Community 4.0.d on Windows XP

curl -v -X POST -F filedata=@myUpload.doc -F siteid=mysite -F containerid=documentLibrary -F uploaddirectory=/uploads http://username:password@localhost:8080/alfresco/service/api/upload

This will upload into documentLibrary/uploads within the specific Share site (mysite). Note that the user performing the upload must be a member of that Share site (and presumably needs at least Contributor access?).

I'm unsure why the leading slash is needed for the uploaddirectory, since the script seems to remove it again. But omitting it causes the file to be saved into the parent folder i.e. documentLibrary!

The actual webscript is located in tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\repository\upload - looking at the source is the best way to understand it as the online Alfresco documentation is not very detailed (http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FRESTful-U...)