Home
Add a file using a multipart POST
Add a file to your library using a multipart POST.
See Authenticating requests for information about how to authenticate the request.
Atom API request details
Method Resource address Input representation Description POST /basic/api/myuserlibrary/feed multipart post Adds the binary data and creates a file Atom document containing the metadata of a file to your library.
You can use one or more of these headers.
Input headers
Parameter Required Description Content-Type No Used to specify the mime type for the content being sent to the server. If the collection does not support the specified content type, the server returns HTTP response code 415 (Unsupported media type). When a media resource is posted, the mime-type of the resource is set to this value if it is provided. Otherwise, the mime-type of the extension of the Slug header is used. A Content-Type that is an empty string, whitespace only, or equal to "unknown/unknown" is considered to be not-specified. Content-Language No Specifies the language of the content being sent to the server. All contents are handled using UTF-8 encoding on the server. Content-Length No Specifies the content length when sending media content. Slug Yes Contains the file path and label of the resource to be added to the collection. You can include non-ASCII characters in this header, but they must be properly encoded according to the RFC 2047.
You can include one or more of these parameters in the body of the request.
Parameters
Parameter Description commentNotification String. Specifies whether you want to get a notification when someone adds or updates a comment on a file. Options are on or off. Default to on. description Summary of the document in plain text. file Contains the binary media of the file. mediaNotification String. Specifies whether the person updating the file wants to get a notification when someone subsequently updates the file. Options are on or off. Default to on. sharePermission Defines the level of permission that the people listed in the sharedWith parameter have to the file. Only applicable if the sharedWith parameter is passed. Permission level options are Edit or View. shareSummary Text. Explanation of the share. shareWith User ID of the user to share the content with. This parameter can be applied multiple times. Supports multivalue. tag String. Keyword that helps to classify the file. This parameter can be applied multiple times if multiple tags are passed. Supports multivalue. visibility String. Specifies who can see the file. Options are private or public. A public file is visible to all users and can be shared by all users.
Input
A multipart post in which each parameter has a Content-Disposition: form-data, and the name is the parameter name.
Output
An Atom entry document representing the new file. Returned HTTP Headers
- HTTP/1.1 201 Created
- Indicates that the file entry was successfully created. If an error occurs, this header will contain one of the error codes below.
Error codes
- HTTP/1.1 401 Unauthorized
- HTTP/1.1 404 Not Found
Sample multipart post content to add an image file to the library:
POST /files/form/api/myuserlibrary/feed?opId=upload%2CSample%20file%202.gif%2C1248801819927&format=html&If-Match=uid%3Ddsmith&X-Update-Nonce=041F091B9K82A25E19B0E3559050C7000001 HTTP/1.1 Host: enterprise.acme.com:9080 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,ko;q=0.9,ja;q=0.7,cs;q=0.6,th;q=0.4,zh;q=0.3,en;q=0.1 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://enterprise.acme.com:9080/files/app?lang=en Cookie: ... Content-Type: multipart/form-data; boundary=---------------------------231991966824484 Content-Length: 2810 -----------------------------231991966824484 Content-Disposition: form-data; name="file"; filename="iconShare.gif" Content-Type: image/gif < binary data here, 1326 bytes total > -----------------------------231991966824484 Content-Disposition: form-data; name="visibility" public -----------------------------231991966824484 Content-Disposition: form-data; name="propagate" true -----------------------------231991966824484 Content-Disposition: form-data; name="shareWithEditors" -----------------------------231991966824484 Content-Disposition: form-data; name="shareWithViewers" -----------------------------231991966824484 Content-Disposition: form-data; name="shareSummary" -----------------------------231991966824484 Content-Disposition: form-data; name="tag" tag3 -----------------------------231991966824484 Content-Disposition: form-data; name="tag" tag4 -----------------------------231991966824484 Content-Disposition: form-data; name="tag" tag5 -----------------------------231991966824484 Content-Disposition: form-data; name="label" Sample file 2.gif -----------------------------231991966824484 Content-Disposition: form-data; name="notification" on -----------------------------231991966824484 Content-Disposition: form-data; name="If-Match" uid=dsmith -----------------------------231991966824484 Content-Disposition: form-data; name="X-Update-Nonce" 041F091B9K82A25E19B0E3559050C7000001 -----------------------------231991966824484--
Related reference