Adding a file attachment
Added by IBM contributorIBM | Edited by Claudia R Elbourn on June 30, 2015
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Add a file attachment to a file in your library.
To create an attachment, the currently authenticated user must be the owner of the user library containing the document, an administrator, or have been shared with as an editor. To test whether the current user can create a file attachment, use the Retrieving file metadata API with the acls parameter set to true, and check the element for the AddChild flag.

Note: {document-id} is the value of the <td:uuid> or <td:label> element in the Atom entry document of the file to which you want to add the attachment.

You can use one or more of these input parameters and headers. Separate multiple parameters with an ampersand (&).

The following types of file attachments are supported:

  • Media resource
  • Multipart content
If done properly, you will make an Atom entry document representing the new file attachment.
Input
Method URI Description
POST /files/{auth}/api/myuserlibrary/document/{document-id}/feed Adds a file attachment to a file in your library.
Content Type: application/atom+xml
Sample Request:
<?xml version="1.0"?>

<entry 

 xmlns="http://www.w3.org/2005/Atom" 

 xmlns:snx="http://www.ibm.com/xmlns/prod/sn">

<id>ignored</id>

<title>ignored</title>

<author>

<name>ignored</name> <!-- taken from authenticated moderator user -->

</author>

<snx:in-ref-to xmlns:snx="http://www.ibm.com/xmlns/prod/sn" 

   rel="http://www.ibm.com/xmlns/prod/sn/report-item" 

   ref-item-type="document"                

   ref="f6740167-0e17-4dd6-b54d-01d3282a228b">

</snx:in-ref-to> 

<snx:moderation action="approve" />\

<content>This content of this entry is not objectionable according to 

 company guidelines.</content>

</entry>
Name Type Optional Description
document-id
string No {document-id} is the value of the <td:uuid> or <td:label> element in the Atom entry document of the file to which you want to add the attachment.
auth
enumerated No The authorization protocol being used by your application to access Connections Cloud.
Authorized values:
  • basic
  • oauth
Name Type Optional Description
created
number Yes Date to use as the creation date of the file attachment. Specify the time in the number of milliseconds since 1 January 1970, 00:00:00 GMT. This value can be set by the user, and defaults to the current system time on the server.
identifier
string Yes Indicates how the document is identified in the {document-id} variable segment of the web address. By default, the lookup operation is performed with the expectation that the URL contains the value from the <td:uuid> element of a attachment Atom entry, so the value uuid is used. Specify label if the URL instead contains the value from the <td:label> element of a attachment Atom entry.
modified
number Yes Date to use as the last modified date of the file attachment. Specify the time in the number of milliseconds since January 1, 1970, 00:00:00 GMT time. This value can be set by the user, and defaults to the current system time on the server.
replace
boolean Yes Specifies whether to replace an existing attachment, if there is one. Options are true or false. The default value is false.
Name Type Optional Description
Content-Type
string Yes 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. If this header is not present on the request, then the server returns a HTTP response code of 400 (Bad request).
Content-Language
string Yes Specifies the language of the content being sent to the server. All contents are handled using UTF-8 encoding on the server.
Content-Length
string Yes Specifies the content length when sending media content. If this header is not present on the request, then the server returns a HTTP response code of 411 (Length required).
Slug
string Yes Contains the file path and label of the resource to be added to the file. You can include non-ASCII characters in this header, but they must be correctly encoded according to RFC 2047.
X-Update-Nonce
string Yes String. Represents a unique data string generated by the server upon request that you can provide to secure the request. See Getting a nonce key for information about how to request the data string.
Authorization
enumerated No The authentication mechanism selected by your application to access the API.
Basic is the Base64 encoding of the IBM Connections Cloud username and password: Base64(username:password). For example, Base64(twatson@us.ibm.com:password).
Bearer is the oauth 2.0 access token that is generated when the user grants your application access to IBM Connections Cloud services.
See the reference topic "OAuth 2.0 APIs for web server flow" for more information.
Authorized values:
  • bearer
  • basic
Output
Content Type: application/atom+xml
Code Description
201
Indicates that the file attachment was successfully created. If an error occurs, this header contains one of the error codes.
401
Unauthorized.
403
Forbidden.
404
Not Found.
409
Conflict.
411
Length required.
415
Unsupported media type