Example of RESTful upload using curl please.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2010 06:01 PM
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.
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.
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2010 09:58 AM
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
In case if you haven't
here is the link.
http://ecmarchitect.com/archives/2009/04/10/959

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2010 11:06 AM
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
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2010 11:18 AM
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)

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2012 07:59 AM
Simple example, tested against Alfresco Community 4.0.d on Windows XP
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...)
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...)
