Document Navigation
Container Resource Operations
Contact Resource Operations
Tag Resource Operations
RecycleBin Resource Operations
Metadata Resource Operations
File Resource Operations

The intent of this document is to walk you through some basic operations of the Cloud Storage Platform API. After completing this howto, you should feel comfortable with the basic operations of the Cloud Storage Platform API and be able to begin creating your own application that leverages cloud storage.


Minor text editing to create the XML snippets used as input to create the different resources in the API will be needed.


Note: The GUID values will be different for each user and for each item created since they are globally unique.


Note:“$Key”represents your client (API) key. You will need to specify it for each operation.


This howto will use the following command line programs:

  • curl (http://curl.haxx.se/)
  • xmlstarlet (http://xmlstar.sourceforge.net/)

For a more in-depth description of the Cloud Storage Platform API, please reference the Developer Guide.


Container Listing Operation


Each user has a root container that contains all the files and containers that are created and placed in the system using the API.


To get started with the API, let us use curl to do a HTTP/1.1 GET on the root resource to retrieve all the resources that are available to you:


Example curl command:
curl -u $cred -H ‘X-Client-Specification: 2’ –H ‘X-Cloud-Key: $Key’\ -X GET https://api.example.com/v2 | xml fo

This will return a Cloud resource listing similar to the following which contains a URI for the root container:

<?xml version="1.0" encoding="UTF-8"?>
<cloud xmlns:xlink="http://www.w3.org/1999/xlink">
  <rootContainer xlink:href="https://api.example.com/v2/containers/9EC89EB0" xlink:type="simple"/>
  <contacts xlink:href="https://api.example.com/v2/contacts" xlink:type="simple"/>
  <shares xlink:href="https://api.example.com/v2/shares" xlink:type="simple"/>
  <metacontainers xlink:href="https://api.example.com/v2/metacontainers" xlink:type="simple"/>
  <account xlink:href="https://api.example.com/v2/account" xlink:type="simple"/>
  <tags xlink:href="https://api.example.com/v2/tags" xlink:type="simple"/>
  <recyclebin xlink:href="https://api.example.com/v2/recyclebin" xlink:type="simple"/ >
</cloud>

To retrieve information regarding the rootContainer, run the following command:


Example curl command:
curl -u <username>:<password> https://api.example.com/v2/containers/9EC89EB0 | xml fo

<?xml version="1.0" encoding="UTF-8"?>
<container xmlns:xlink="http://www.w3.org/1999/xlink">
  <name>/</name>
  <created>1246900106</created>
  <inproject>False</inproject>
  <modified>1248120109</modified>
  <owner>username@api.example.com</owner>
  <version>0</version>
  <shared>False</shared>
  <accessed>1248120109</accessed>
  <bytes>307219976</bytes>
  <contents xlink:href="https://api.example.com/v2/containers/9EC89EB0/contents" xlink:type="simple"/>
  <tags xlink:href="https://api.example.com/v2/containers/9EC89EB0/tags" xlink:type="simple"/>
  <parent xlink:href="https://api.example.com/v2/containers/9EC89EB0" xlink:type="simple"/>
</container>

To list the files and containers already present inside the rootContainer, run the following command: Notice that the URI used is the same as the one returned in the cloud result above with /contents added to the end. Example curl command:
curl -u <username>:<password> \ https://api.example.com/v2/containers/9EC89EB0/contents \ | xml fo
                        
<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <container xlink:href="https://api.example.com/v2/containers/782B9650" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/files/539C8EBC" xlink:type="simple"/>
</file-list>

In this case, there is 1 container and 1 file present inside the rootContainer. You can recursively do a HTTP/1.1 GET on the container to retrieve its contents by appending the /contents directive to the URI returned by the file listing.

Container Create Operation

Containers are created by HTTP/1.1 POSTing an xml document conforming to the application/vnd.csp.container-info+xml schema. An arbitrary number of containers may be created by the user. There is also no constraint on the hierarchical structure of the containers. To create a new container with the name “New container” inside the rootContainer, use curl to do a HTTP/1.1 POST of a file with the following xml as the contents to the rootContainer contents resource: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.container-info+xml.

newcontainer.xml

                        
<container>
 <name>New container</name>
</container>

Example curl command:
curl -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.container-info+xml' \ https://api.example.com/v2/containers/9EC89EB0/contents -d @newcontainer.xml
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes. Listing the root container contents at this point will show that the container has been added to the listing.
                        
<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <container xlink:href="https://api.example.com/v2/containers/782B9650" xlink:type="simple"/>
  <container xlink:href="https://api.example.com/v2/containers/B22DA7BA" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/files/539C8EBC" xlink:type="simple"/>
</file-list>

Container Rename Operation

Containers are renamed by doing an HTTP/1.1 PUT of an xml document conforming to the application/vnd.csp.container-info+xml schema to the resource oid URI. To rename the container “New container” created inside the rootContainer in the last section, we will do a HTTP/1.1 PUT of a file with the following xml as the contents to the URI of the container we created: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.container-info+xml.

updatecontainer.xml

                        
<container>
 <name>Renamed Container</name>
</container>

Example curl command:
curl -v -u <username>:<password> -X PUT \ -H 'Content-Type: application/vnd.csp.container-info+xml' \ https://api.example.com/v2/containers/B22DA7BA -d @updatecontainer.xml
There is no response text from this operation unless an error was encountered.

Container Move Operation

Containers are moved by doing an HTTP/1.1 PUT of an xml document conforming to the application/vnd.csp.container-info+xml schema to the resource oid URI. To move the container “Renamed container” that was renamed in the last section, we will do a HTTP/1.1 PUT of a file with the following xml as the contents to the URI of the container. To move the container to a different container the parent URI of the destination container must be specified. Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.container-info+xml.

updatecontainer.xml

                        
<container>
 <parent xlink:href="https://api.example.com/v2/containers/E0463284" xlink:type="simple"/>
</container>
Example curl command:
curl -v -u <username>:<password> -X PUT \ -H 'Content-Type: application/vnd.csp.container-info+xml' \ https://api.example.com/v2/containers/B22DA7BA -d @updatecontainer.xml
There is no response text from this operation unless an error was encountered.

Container Copy Operation

Containers are copied by doing an HTTP/1.1 POST of an empty xml document conforming to the application/vnd.csp.container-info+xml schema to the destination container “/contents” URI. The header “Content-Location” must also be specified which denotes the actual URI of the resource to be copied. To move the container “Renamed container” that was renamed in the last section, we will do a HTTP/1.1 POST of a file with the following xml as the contents to the URI of the container. The name of the destination container may also be changed by specifying the new name in the “X-Cloud-Name” header. Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.container-info+xml. >copycontainer.xml

                        
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns:xlink="http://www.w3.org/1999/xlink">
</container>
Example curl command:
curl -v -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.container-info+xml' \ -H 'Content-Location: https://api.example.com/v2/containers/B22DA7BA' \ https://api.example.com/v2/containers/782B9650/contents -d @copycontainer.xml
There is no response text from this operation unless an error was encountered.

Container Delete Operation

Containers are deleted by doing an HTTP/1.1 DELETE to the resource URI. Example curl command:
curl -v -u <username>:<password> -X DELETE \ https://api.example.com/v2/containers/B22DA7BA
There is no response text from this operation unless an error was encountered.

Contact Listing Operation

Each user has a resource that will return the list of contacts that the user has stored using the API. To retrieve the list of contacts stored by the system, let us use curl to do a HTTP/1.1 GET on the contacts resource: Example curl command:
curl -u <username>:<password> -X GET https://api.example.com/v2/contacts | xml fo
This will return a Contacts resource listing similar to the following which contains a URI for each contact stored in the system:

<?xml version="1.0" encoding="UTF-8"?><contacts xmlns:xlink="http://www.w3.org/1999/xlink">
  <contact xlink:href="https://api.example.com/v2/contacts/4121DDB8" xlink:type="simple"/>
</contacts>

To retrieve information about the contact defined, run the following command: Example curl command:
curl -u <username>:<password> https://api.example.com/v2/contacts/4121DDB8 | xml fo
                                
<?xml version="1.0" encoding="UTF-8"?>
<contact>
  <firstname>FirstName</firstname>
  <lastname>LastName</lastname>
  <email>firstlast@api.example.com</email>
</contact>

                            

Contact Create Operation

Contacts are created by POSTing an xml document conforming to the application/vnd.csp.contact-info+xml schema. An arbitrary number of contacts may be created by the user. To create a new contact, use curl to do a HTTP/1.1 POST of a file with the following xml as the contents to the contacts resource: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.contact-info+xml. newcontact.xml
                                
<contact>
 <firstname>John</firstname>
 <lastname>Doe</lastname>
 <email>john.doe@api.example.com</email>
</contact>

                            
Example curl command:
curl -u <username>:<password> -X POST -H 'Content-Type: application/vnd.csp.contact+xml' https://api.example.com/v2/contacts -d @newcontact.xml
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes. Listing the contacts at this point will show that the nexw contact has been added to the listing.
                                
<?xml version="1.0" encoding="UTF-8"?>
<contacts xmlns:xlink="http://www.w3.org/1999/xlink">
  <contact xlink:href="https://api.example.com/v2/contacts/4121DDB8" xlink:type="simple"/>
  <contact xlink:href="https://api.example.com/v2/contacts/1440339C" xlink:type="simple"/>
</contacts>

                            

Contact Update Operation

Contact details may be updated by doing an HTTP/1.1 PUT of an xml document conforming to the application/vnd.csp.contact+xml schema to the resource oid URI. To update the contact created in the last section, we will do a HTTP/1.1 PUT of a file with the following xml as the contents to the URI of the contact we created: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.contact+xml. updatecontact.xml
                                
<contact>
 <firstname>John</firstname>
 <lastname>Doe</lastname>
 <email>john@doe.com</email>
</contact>

                            
Example curl command:
curl -u <username>:<password> -X PUT \ -H 'Content-Type: application/vnd.csp.contact+xml' \ https://api.example.com/v2/contacts/1440339C -d @updatecontact.xml
There is no response text from this operation unless an error was encountered.

Contact Delete Operation

Contacts are deleted by doing an HTTP/1.1 DELETE to the resource URI. Example curl command:
curl -u <username>:<password> -X DELETE https://api.example.com/v2/contacts/1440339C
There is no response text from this operation unless an error was encountered.

Shared Items Listing Operation

Each user has a resource that lists all the files and containers that are shared to them by other users. To get the list of shared items, let us use curl to do a HTTP/1.1 GET on the “shares” resource to retrieve all the items that are available: Example curl command:
curl -u <username>:<password> -X GET https://api.example.com/v2/shares | xml fo
This will return a Container contents listing similar to the following which contains a URI for each file/container shared in the system:
                                
<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <file xlink:href="https://api.example.com/v2/files/539C8EBC" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/files/C6553BAC" xlink:type="simple"/>
</file-list>

                            
To retrieve information about the first item shared, run the following command: Example curl command:
curl -u <username>:<password> https://api.example.com/v2/files/539C8EBC | xml fo
                                
<?xml version="1.0" encoding="UTF-8"?>
<file xmlns:xlink="http://www.w3.org/1999/xlink">
  <name>shared-file.dat</name>
  <created>1247062329</created>
  <inproject>False</inproject>
  <modified>1247062329</modified>
  <owner>john.doe@api.example.com</owner>
  <version>1</version>
  <shared>True</shared>
  <accessed>1247062329</accessed>
  <public>false</public>
  <mime_type>application/octet-stream</mime_type>
  <bytes>307200000</bytes>
  <content xlink:href="https://api.example.com/v2/files/539C8EBC/content" xlink:type="simple"/>
  <parent xlink:href="https://api.example.com/v2/containers/9EC89EB0" xlink:type="simple"/>
  <permissions xlink:href="https://api.example.com/v2/files/539C8EBC/permissions" xlink:type="simple"/>
  <tags xlink:href="https://api.example.com/v2/files/539C8EBC/tags" xlink:type="simple"/>
  <thumbnail xlink:href="https://api.example.com/v2/files/539C8EBC/thumbnail" xlink:type="simple"/>
</file>

                            

Share Permissions Assignment Operation

Users are given permissions to access projects by doing an HTTP/1.1 POST to the project’s permissions URI. Users may be given permissions to a project by doing an HTTP/1.1 POST of an xml document conforming to the application/vnd.csp.permission+xml schema to the project’s “/permissions” URI. To assign a file to the project created in the last section, we will do a HTTP/1.1 POST of a file with the following xml as the contents to the URI of the project we created: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.permission+xml. permissions.xml
                                
<permission>
 <grantee>john.doe@example.com</grantee>
 <expiration/>
 <permissions>rw</permissions>
</permission>

                            
To assign permissions to john.doe@example.com to the project created previously, run the following command: Example curl command:
curl -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.permission+xml' \ https://api.example.com/v2/projects/797B1992/permissions -d @permissions.xml
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes.

Share Permissions Removal Operation

Permissions to a file/folder are removed by doing an HTTP/1.1 DELETE to the file/folder’s permission resource URI. To remove permissions for john.doe@example.com from the file prev iously granted in the steps above, run the following command: Example curl command:
curl -u <username>:<password> -X DELETE https://api.example.com/v2/files//permissions/
There is no response text from this operation unless an error was encountered.

Tag Listing Operation

Each user has a resource that will return the list of tags that the user has applied to items in the cloud. To retrieve the list of tags stored by the system, let us use curl to do a HTTP/1.1 GET on the tags resource: Example curl command:
curl -u <username>:<password> -X GET https://api.example.com/v2/tags | xml fo
This will return a Tags resource listing similar to the following which contains a URI for each contact stored in the system:

<?xml version="1.0" encoding="UTF-8"?>
<tags xmlns:xlink="http://www.w3.org/1999/xlink">
  <tag
    xlink:href="https://api.example.com/v2/tags/NewTag"
    xlink:type="simple"/>
</tags>
To retrieve information about the tag defined, run the following command: Example curl command:
curl -u <username>:<password> https://api.example.com/v2/tags/NewTag | xml fo

<?xml version="1.0" encoding="UTF-8"?>
<tag xmlns:xlink="http://www.w3.org/1999/xlink">
  <name>NewTag</name>
  <objects
    xlink:href="https://api.example.com/v2/tags/NewTag/objects"
    xlink:type="simple"/>
</tag>
To retrieve information about the objects to which this tag is applied, run the following command: Example curl command:
curl -u <username>:<password> https://api.example.com/v2/tags/NewTag/objects | xml fo

<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <file xlink:href="https://api.example.com/v2/files/CE0D4812" xlink:type="simple"/>
</file-list>

Tag Create Operation

Tags are created and applied to objects by POSTing an xml document conforming to the application/vnd.csp.tag-info+xml schema. An arbitrary number of tags may be created by the user. Each tag may also be applied to one or more items stored in the cloud. To create a new tag, use curl to do a HTTP/1.1 POST of a file with the following xml as the contents to the “/tags” resource of the item you wish to tag: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.tag-info+xml. tag.xml

<tag>
  <name>New Tag2</name>
</tag>
Example curl command:
curl -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.tag-info+xml' \ https://api.example.com/v2/files/CE0D4812/tags -d @tag.xml
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes. Listing the “tags” resource at this point will show that the new tag has been added to the listing.

<?xml version="1.0" encoding="UTF-8"?>
<tags xmlns:xlink="http://www.w3.org/1999/xlink">
  <tag xlink:href="https://api.example.com/v2/tags/NewTag" xlink:type="simple"/>
  <tag xlink:href="https://api.example.com/v2/tags/New%20Tag2" xlink:type="simple"/>
</tags>

Tag Deletion Operation

Tags on an item are removed by doing an HTTP/1.1 DELETE to the item’s “/tag/” resource URI. To remove a tag from the first file tagged in the steps above, run the following command: Example curl command:
curl -u <username>:<password> -X DELETE \ https://api.example.com/v2/files/CE0D4812/tags/New%20Tag2
There is no response text from this operation unless an error was encountered.

RecycleBin Listing Operation

Each user has a recylebin resource that will return the list of items that have been deleted. To retrieve the list of recycled items, let us use curl to do a HTTP/1.1 GET on the recyclebin resource: Example curl command:
curl -u <username>:<password> -X GET https://api.example.com/v2/recyclebin | xml fo
This will return a RecycleBin resource listing similar to the following which contains a URI for each item deleted from the system:

<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <container xlink:href="https://api.example.com/v2/recyclebin/782B9650" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/recyclebin/539C8EBC" xlink:type="simple"/>
</file-list>
To retrieve information about the deleted container, run the following command: Example curl command:
curl -u <username>:<password> https://api.example.com/v2/recyclebin/782B9650 | xml fo

<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <container
    xlink:href="https://api.example.com/v2/recyclebin/782B9650" xlink:type="simple"/>
    <bytes>0</bytes>
    <originalname>Renamed Container</originalname>
    <recycleddate>1248212805</recycleddate>
  </container>
</file-list>

RecycleBin Item Deletion Operation

Items in the RecycleBin may be deleted permanently by doing an HTTP/1.1 DELETE to the item’s recyclebin resource URI. To remove the container from the example above, run the following command: Example curl command:
curl -u <username>:<password> -X DELETE \ https://api.example.com/v2/recyclebin/782B9650
There is no response text from this operation unless an error was encountered.

RecycleBin Item Restore Operation

Items in the RecycleBin may be restored to their original location by doing an HTTP/1.1 RESTORE to the item’s recyclebin resource URI. To restore the file from the example above, run the following command: Example curl command:
curl -u <username>:<password> -X RESTORE \ https://api.example.com/v2/recyclebin/539C8EBC
There is no response text from this operation unless an error was encountered.

MetaData Listing Operation

Arbitrary key/value pair metadata may be assigned to a file/folder. To retrieve the list of metadata items applied to a file, let us use curl to do a HTTP/1.1 GET on a file metadata resource: Example curl command:
curl -u <username>:<password> -X GET https://api.example.com/v2/files/CE0D4812-6A75-11DE-8B5A-BF486DC27EE3/metadata | xml fo
This will return a MetaData resource listing similar to the following which contains a URI for each metadata item:

<?xml version="1.0" encoding="UTF-8"?>
<metadata-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <metadata-item xlink:href="https://api.example.com/v2/files/CE0D4812/metadata/example"
     xlink:type="simple"/>
</metadata-list>

To retrieve information about the first metadata item container, run the following command: Example curl command:
curl -u <username>:<password> \ https://api.example.com/v2/files/CE0D4812/metadata/example | xml fo

<application>
  <code>ED09</code>
</application>

MetaData Create Operation

Metadata is created and applied to objects by doing an HTTP/1.1 PUT of the arbitrary data. This information is not interpreted or otherwise altered by the system. You may also specify the “Content-Type” of the data being posted and when it is returned this value will be as well. To create a new metadata key/value pair, use curl to do a HTTP/1.1 PUT of the data you wish to be associated with the key to the “/metadata/” URI of the item you wish to tag: Note: The HTTP Content-Type may be specified if your data has one. note.txt

This is the note contents.
Example curl command:
curl -u <username>:<password> -X PUT \ -H 'Content-Type: application/txt' \ https://api.example.com/v2/files/CE0D4812/metadata/note -d @note.txt
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes. Listing the “metadata” resource at this point will show that the new metadata has been added to the listing.

<?xml version="1.0" encoding="UTF-8"?>
<metadata-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <metadata-item xlink:href="https://api.example.com/v2/files/CE0D4812/metadata/example"
    xlink:type="simple"/>
  <metadata-item xlink:href="https://api.example.com/v2/files/CE0D4812/metadata/note"
    xlink:type="simple"/>
</metadata-list>

MetaData Get Operation

Metadata is retrieved by doing an HTTP/1.1 GET on the URI of the resource. Retrieving the “note” metadata item that we created in the last step is done as follows: Example curl command:
curl -u <username>:<password> -X GET \ https://api.example.com/v2/files/CE0D4812/metadata/note
The “Content-Type” of the response will be “application/txt” since that is what was set when it was created. You must supply the -v option to curl to see the HTTP headers in the response.
This is the note contents.

Metadata Deletion Operation

Metadata applied to resources may be deleted by doing an HTTP/1.1 DELETE to the item’s resource URI. To remove the metadata from the example above, run the following command: Example curl command:
curl -u <username>:<password> -X DELETE \ https://api.example.com/v2/files/CE0D4812/metadata/note
There is no response text from this operation unless an error was encountered.

File Upload

The API is very flexible in the methods in which files are uploaded. File uploads can be accomplished two different ways.
  • Multi-part form upload Use a multi-part form upload Uploads the file all at once. Required form elements:
    • filename – name of the file to create
    • form-data – binary file contents
    Example curl command:
    curl -u <username>:<password> -F "file=@testfile.txt;filename=testfile.txt" https://api.example.com/v2/containers/9EC89EB0/contents
  • Two-part process
    • Create the file resource
    • Upload the file in one or more pieces using HTTP/1.1 PUT Example curl command:
      curl -u <username>:<password> -X PUT \ https://api.example.com/v2/files/CE0D4812/content --data-binary @filedata.bin

File Create Operation (Empty)

Files can be created by HTTP/1.1 POSTing an xml document conforming to the application/vnd.csp.file-info+xml schema. To create a new text file with the name “testfile.txt” inside the rootContainer, use curl to do a HTTP/1.1 POST of a file with the following xml as the contents to the rootContainer contents resource: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.file-info+xml. newfile.xml

<file>
 <name>testfile.txt</name>
 <mime_type>text/plain</mime_type>
 <public>false</public>
</file>

Example curl command:
curl -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.file-info+xml' \ https://api.example.com/v2/containers/9EC89EB0/contents -d @newfile.xml
The response from the request will be a “text/uri-list” item which will be the URI of the created resource. The header “HTTP/1.1 201 Created” is returned on success. You must supply the -v option to curl to see the HTTP response codes. Listing the root container contents at this point will show that the file has been added to the listing. To add data to this new file HTTP/1.1 PUT the data to the “/contents” of the resource URI that was created.

<?xml version="1.0" encoding="UTF-8"?>
<file-list xmlns:xlink="http://www.w3.org/1999/xlink">
  <container xlink:href="https://api.example.com/v2/containers/782B9650" xlink:type="simple"/>
  <container xlink:href="https://api.example.com/v2/containers/B22DA7BA" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/files/539C8EBC" xlink:type="simple"/>
  <file xlink:href="https://api.example.com/v2/files/4B6B15E4" xlink:type="simple"/>
</file-list>

File Rename Operation

Files are renamed by doing an HTTP/1.1 PUT of an xml document conforming to the application/vnd.csp.file-info+xml schema to the resource URI. To rename a file “testfile.txt” created inside the rootContainer in the last section, we will do a HTTP/1.1 PUT of a file with the following xml as the contents to the URI of the file we created: Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.file-info+xml. updatefile.xml

<file>
 <name>test file renamed.txt</name>
 <mime_type>text/plain</mime_type>
 <public>false</public>
</file>

Example curl command:
curl -v -u <username>:<password> -X PUT \ -H 'Content-Type: application/vnd.csp.file-info+xml' \ https://api.example.com/v2/files/4B6B15E4 -d @updatefile.xml
There is no response text from this operation unless an error was encountered.

File Move Operation

Files are moved by doing an HTTP/1.1 PUT of an xml document conforming to the application/vnd.csp.file-info+xml schema to the resource oid URI. To move the file “test file renamed.txt” that was renamed in the last section, we will do a HTTP/1.1 PUT of a file with the following xml as the contents to the URI of the container. To move the file to a different container the parent URI of the destination container must be specified. Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.file-info+xml. updatefile.xml
                                                    
<file xmlns:xlink="http://www.w3.org/1999/xlink">
 <name>testfile.txt</name>
 <mime_type>text/plain</mime_type>
 <public>false</public>
 <parent xlink:href="https://api.example.com/v2/containers/E0463284" xlink:type="simple"/>
</file>
Example curl command:
curl -v -u <username>:<password> -X PUT \ -H 'Content-Type: application/vnd.csp.file-info+xml' \ https://api.example.com/v2/containers/B22DA7BA -d @updatefile.xml
There is no response text from this operation unless an error was encountered.

File Copy Operation

Files are copied by doing an HTTP/1.1 POST of an empty xml document conforming to the application/vnd.csp.file-info+xml schema to the destination container “/contents” URI. The header “Content-Location” must also be specified which denotes the actual URI of the resource to be copied. To copy the file “test file renamed.txt” that was copied in the last section, we will do a HTTP/1.1 POST of a file with the following xml as the contents to the URI of the container. Note: The HTTP Content-Type must be specified correctly as: application/vnd.csp.file-info+xml. copyfile.xml
                        
<?xml version="1.0" encoding="UTF-8"?>
<file xmlns:xlink="http://www.w3.org/1999/xlink">
</file>
Example curl command:
curl -v -u <username>:<password> -X POST \ -H 'Content-Type: application/vnd.csp.file-info+xml' \ -H 'Content-Location: https://api.example.com/v2/containers/B22DA7BA' \ https://api.example.com/v2/containers/782B9650/contents -d @copyfile.xml
There is no response text from this operation unless an error was encountered.

File Delete Operation

Files are deleted by doing an HTTP/1.1 DELETE to the resource URI. Example curl command:
curl -v -u <username>:<password> -X DELETE https://api.example.com/v2/files/4B6B15E4
There is no response text from this operation unless an error was encountered.