Storage API documentation

Introduction

The API enables integration with third party applications.

  • The API is REST
  • The API accepts only HTTPS requests
  • All function calls need authorization and authentication (Basic HTTP)

To authenticate using HTTP Basic use your CDN Storage username and password combination. Curl example:

curl --user username:password

HTTP methods

The API uses the following HTTP methods:

GETUsed for retrieving information, e.g., list a directory
POSTUsed for creating new objects, e.g., create a directory
PUTUsed for altering object properties and uploading files
DELETEUsed for object deletion, e.g., delete a directory

Curl example

curl --user username:password --include --request POST --header 'Accept: application/json' --header 'Content-type: application/json' --url https://push-XX.cdnsun.com/content --data '{"content":{"path":"/images"}}'

HTTP response codes

The API returns appropriate HTTP status code for every request.

HTTP response bodies

The API returns appropriate HTTP response body for every request:

SuccessError
{
    "status": "success",
    "response_code": 200,
    "resource": "content",
    "action": "post",
    "message": "success",
    "data": {
        "path": "/images
    }
}
{
    "status": "error",
    "response_code": 401,
    "resource": "index",
    "action": "index",
    "message": "you are not authorized",
    "data": null
}

Documentation

  • Upload a file
    • URL: /content
    • Method: PUT
    • Params sources: GET, RAW REQUEST BODY
    • Request HTTP headers: Accept: application/json
    • Params:
      • path
        • Name: path
        • Data type: string
        • Example: /dir
        • Note: Allowed characters are a-z, A-Z, 0-9, -, _, . and /. Must not end with a slash / (must represent a file name not a directory name).
    • Mandatory: path
    • Curl example: curl --user username:password --include --request PUT --header 'Accept: application/json' --url https://push-XX.cdnsun.com/content?path=/dir/file --upload-file /path/to/your/local/file
    • Note: The entire PUT body will be treated as the file.
  • List a directory
    • URL: /content
    • Method: GET
    • Params sources: GET
    • Request HTTP headers: Accept: application/json
    • Params:
      • path
        • Name: path
        • Data type: string
        • Example: /dir
        • Note: Allowed characters are a-z, A-Z, 0-9, -, _, . and /.
    • Mandatory: path
    • Curl example: curl --user username:password --include --request GET --header 'Accept: application/json' --url https://push-XX.cdnsun.com/content?path=/
  • Create a directory
    • URL: /content
    • Method: POST
    • Params sources: POST (JSON)
    • Request HTTP headers: Content-type: application/json, Accept: application/json
    • Params:
      • path
        • Name: path
        • Data type: string
        • Example: /dir
        • Note: Allowed characters are a-z, A-Z, 0-9, -, _, . and /.
    • Mandatory: path
    • Curl example: curl --user username:password --include --request POST --header 'Content-type: application/json' --header 'Accept: application/json' --url https://push-XX.cdnsun.com/content --data '{"content":{"path":"\/dir"}}'
  • Remove a file or directory
    • URL: /content
    • Method: DELETE
    • Params sources: POST (JSON)
    • Request HTTP headers: Content-type: application/json, Accept: application/json
    • Params:
      • path
        • Name: path
        • Data type: string
        • Example: /dir
        • Note: Allowed characters are a-z, A-Z, 0-9, -, _, . and /.
    • Mandatory: path
    • Curl example: curl --user username:password --include --request DELETE --header 'Content-type: application/json' --header 'Accept: application/json' --url https://push-XX.cdnsun.com/content --data '{"content":{"path":"\/dir\/file"}}'

Please replace push-XX.cdnsun.com with the hostname of your storage, e.g., push-11.cdnsun.com.

What next?

Read about the following topics.

Contact Us

  ____     __   __    ______  
 |  _ \\   \ \\/ //  /_____// 
 | |_| ||   \ ` //   `____ `  
 | .  //     | ||    /___//   
 |_|\_\\     |_||    `__ `    
 `-` --`     `-`'    /_//     
                     `-`