Community articleAdding a file to a folder or multiple folders
Added by IBM contributorIBM on June 23, 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 a folder or multiple folders programmatically.



Add a file to a folder or multiple folders programmatically.

URL endpoints


This method requires authentication. In order to add an Item to a Collection, the currently authenticated user must be the owner of the Collection, an Administrator, or have been granted AddChild permission on the Collection. To test whether the current user can add an Item to a Collection, use the Get list of members of a specific role of a Collection to see if the user belongs to the Manager or Contributor Roles.

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

{document-id} is the value of the <td:uuid> or <td:label> elements in the file's Atom entry document.
 

Error Codes


The following error codes could appear in a response body for an invalid request:

Table 4.

Error Code
Description
Unknown
Returned when the cause of an error is unknown
AccessDenied
Returned when the cause of an error is due to a permission restriction
ItemNotFound
Returned when the cause of an error is related to a resource not being found
ItemExists
Returned when the cause of an error is related to a conflict with an existing resource
UnsupportedOperation
Returned when the operation is not supported



 

 

Input
Method URI Description
POST /files/library/{library-id}/document/{document-id-or-label}/feed Add the document to collections specified by atom entry or feed.
POST /files/userlibrary/{user-id}/document/{document-id-or-label}/feed Add the document to collections specified by atom entry or feed.
POST /files/myuserlibrary/document/{document-id-or-label}/feed Add the document to collections specified by atom entry or feed.
POST /files/document/{document-id-or-label/feed Add the document to collections specified by atom entry or feed.
Content Type: application/atom+xml
Sample Request:
<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:td="urn:ibm.com/td">

  <category term="collection" label="collection" scheme="tag:ibm.com,2006:td/type"/>

  <td:itemId>{collection-id}</td:itemId>

  <td:sharePermission>{View|Edit}</td:sharePermission> 

</entry>
Name Type Optional Description
document-id-or-label
string No {document-id-or-label} is the value of the <td:uuid> or <td:label> elements in the file's Atom entry document.
user-id
string Yes The ID of the user.
library-id
string Yes The ID of the library containing the file.
Name Type Optional Description
identifier
enumerated Yes Indicate the identifier used in the document segment of the URL.
Authorized values:
  • uuid
  • label
Name Type Optional Description
Content-Language
string No Used to specify the language for the content being sent to the server. All contents are handled via UTF-8 encoding on the server.
Output
Code Description
204
Indicates that the file was successfully added to the folder or folders. If an error occurs, this header will return an error.
400
Bad Request.
401
Unauthorized.
403
Forbidden.
404
Not Found.
409
Conflict.
Examples
POST /library/1234/document/5678/feed HTTP/1.1

<?xml version="1.0" encoding="UTF-8"?>

<feed>

  <entry xmlns="http://www.w3.org/2005/Atom" xmlns:td="urn:ibm.com/td">

    <category term="collection" label="collection" scheme="tag:ibm.com,2006:td/type"/>

    <td:itemId>{collection-id1}</td:itemId>

    <td:sharePermission>{View|Edit}</td:sharePermission> 

  </entry>

  <entry xmlns="http://www.w3.org/2005/Atom" xmlns:td="urn:ibm.com/td">

    <category term="collection" label="collection" scheme="tag:ibm.com,2006:td/type"/>

    <td:itemId>{collection-id2}</td:itemId>

    <td:sharePermission>{View|Edit}</td:sharePermission> 

  </entry>

  <entry xmlns="http://www.w3.org/2005/Atom" xmlns:td="urn:ibm.com/td">

    <category term="collection" label="collection" scheme="tag:ibm.com,2006:td/type"/>

    <td:itemId>{collection-id3}</td:itemId>

    <td:sharePermission>{View|Edit}</td:sharePermission> 

 

  </entry>

</feed>


Response returned by the server
Location: https://www.example.com:9443/files/basic/collection/c85c0979-22cc-46d5-89b8-be69e0afb912/feed

Status Code: 204(no content)