cancel
Showing results for 
Search instead for 
Did you mean: 

Help and/or Example with the file upload webscript

dallinns
Champ on-the-rise
Champ on-the-rise
I am looking at the Restful API Reference (http://www.alfresco.com/help/33/enterprise/api/) and trying to understand how to use the file upload web script. Currently, the api Reference seems severely under documented.

The web script uses the following HTML form data

Does this mean the service is expecting (multipart/form-data)? or is it expecting XML or something else?

filedata - (mandatory) HTML type file

What is "HTML type file"?

I tried this web script with the following form, assuming that since filedata is the only marked as mandatory that it would work
<form method='POST' enctype='multipart/form-data' action='http://localhost:8080/alfresco/service/api/upload'>            File to upload: <input type="file" name="filedata"><br />            <input type=submit value=Press> to upload the file!        </form>‍‍‍‍

But it returned the following:
{    "status" :   {    "code" : 400,    "name" : "Bad Request",    "description" : "Request sent by the client was syntactically incorrect."  },      "message" : "Required parameters are missing",    "exception" : "",    "callstack" :   [           ],    "server" : "Community v3.4.0 (b 3262) schema 4,111",  "time" : "Mar 18, 2011 3:24:31 PM"}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

What parameters are missing?
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
You have to set all these parameters in your HTML form, as you can see using the WebScripts index:

- filedata, (mandatory) HTML type file
- siteid
- containerid
- uploaddirectory
- updatenoderef
- filename
- description
- contenttype
- majorversion
- overwrite
- thumbnails

The new file must be dropped in one of the Alfresco spaces, this means that you need to set uploaddirectory and the contenttype to specialize the node as you want. The filename is important because Alfresco use this attribute to build the primary path for the content.

Another way is based on implementing your own WebScript following the upload form example webscript to customize some behaviour if you need:
http://wiki.alfresco.com/wiki/Web_Scripts_Examples#File_Upload

Hope this helps.

jrott
Champ in-the-making
Champ in-the-making
Another way is based on implementing your own WebScript following the upload form example webscript to customize some behaviour if you need:
http://wiki.alfresco.com/wiki/Web_Scripts_Examples#File_Upload

Hope this helps.

Hi,

How can we use this in share ? the "companyhome" is not defined there…

Thanks