Community articleAdding a file
Added by IBM contributorIBM on March 21, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Add a file to your library programmatically.



Add a file to your library programmatically.

See Authenticating requests for information about how to authenticate the request.

You can use one or more of these headers.

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

Input

A file consists of both the information about the file, which is also known as metadata, and the binary data that the file contains. You can provide either of the following inputs:

  • Binary data and no Atom entry document to define the metadata. Metadata is created automatically and sets all values to the default values, except for the value of the title element, which it takes from the SLUG header.
  • Atom entry document that defines the metadata of the file and no binary data.

Output

An Atom entry document representing the new file.
Input
Method URI Description
POST /files/basic/api/myuserlibrary/feed Adds a file to your library.
Content Type: text/plain
Name Type Optional Description
commentNotification
enumerated Yes String. Specifies whether you want to get a notification when someone adds or updates a comment on a file. Options are on or off. The default value is on.
Authorized values:
  • on
  • off
created
number Yes Date to use as the creation date of the file. 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.
includePath
boolean Yes Boolean. Specifies whether you want to show the file path to the file. if true , adds an entry extension <td:path> element that specifies the file path to the object. Options are true or false.
mediaNotification
string Yes String. Specifies whether the person updating the file wants to get a notification when someone subsequently updates the file. Options are on or off. The default value is off.
modified
number Yes Date to use as the last modified date of the file. 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.
propagate
boolean Yes Indicates if users that are shared with can share this document. The default value is false.
sharePermission
enumerated Yes 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. The default value is View.
Authorized values:
  • Edit
  • View
shareSummary
string Yes Text. Explanation of the share
shareWith
string Yes User ID of the user to share the content with. This parameter can be applied multiple times. Supports multivalue.
tag
string Yes String. Keyword that helps to classify the file. This parameter can be applied multiple times if multiple tags are passed. Supports multivalue.
visibility
enumerated Yes 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. The default value is private.
Authorized values:
  • private
  • public
Name Type Optional Description
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.
Slug
string No 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.
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.
Output
Content Type: application/atom+xml
Code Description
201
Indicates that the file entry was successfully created. If an error occurs, this header contains one of the error codes.
401
Unauthorized.
403
Forbidden.
404
Not Found.
409
Conflict.
415
Unsupported Media Type.
References