Content Upload

Methods: POST

http://[ZONE_STORAGE_ID]/api/v2/upload

Note: Where your workflow includes video transcoding, the uploads should be sent directly to the transcoder instead of your zone storage ID.

Current maximum file size is 5GB

Parameters
Field Type Description
zone_id integer CDN zone serving the content
folder string A folder or subfolder in which the file will be uploaded, with trailing slash. Leave empty to upload to the root folder. If a non-existing folder is entered, it will be created automatically.
upload_server string Your zone storage ID as reported in your dashboard's CDN Settings tab
Headers
Field Type Description
APIKEY string Account API key
Example

You must pass the file and all parameters, including your API key. Here is how to do it in PHP but you can achieve the same effect in your language of choice. For this example we will use two files - one is our actual upload function and it never changes, while the other is used to pass the parameters to the upload function and we use it dynamically in our workflow to automate the file uploading process:

File: class.uploader.php

<?php
class Uploader 
    {
        var $filePath;
        var $uploadURL;
        var $formFileVariableName;
        var $apiKey;
        var $postParams = array ();

        function Uploader($filePath, $uploadURL, $formFileVariableName, $apiKey, $otherParams = false) 
        {
            $this->filePath = $filePath;
            $this->uploadURL = $uploadURL;
            $this->apiKey = $apiKey;
            if(is_array($otherParams) && $otherParams != false) 
            {
                foreach($otherParams as $fieldName => $fieldValue) 
                {
                    $this->postParams[$fieldName] = $fieldValue;
                }
            }
            $this->postParams[$formFileVariableName] = new \CURLFile($filePath);
        }

        function UploadFile() 
        {            
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('APIKEY:"'.$this->apiKey.'"'));
            curl_setopt($ch, CURLOPT_URL, $this->uploadURL);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postParams);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $postResult = curl_exec($ch);
            echo $postResult;
            if (curl_errno($ch)) 
            {
                print curl_error($ch);
                print "Unable to upload file.";
                exit();
            }
            curl_close($ch);
            return $postResult;
        }
    }

?>

File: new_upload.php

<?php
require_once('class.uploader.php');
$api_key = "2d49e8f645d90818783c4e6c46f32ca0677dc417";
$zone = '318';
$folder = '/tesfile/folder/'; // Leave empty to upload to storage root
$upload_server = "http://s02.pushrcdn.com/api/v2/upload";
$upload = new Uploader('testfile.dat', $upload_server, 'file', $api_key , array('zone_id' => $zone, 'folder' => $folder));
$result = $upload->UploadFile();
?>
Response
HTTP Code JSON Description
200 {"status":"success","URL":"DIRECT_CDN_LINK"} Upload success. Direct link is returned
401 {"status":"error","description":"error message"} Upload failed due to authorization or another error. Error description is returned
520 {"status":"error","description":"error message"} Upload failed due to unknown reasons. Please contact support
Downloads

You can download the code examples and play with them or integrate them directly. They are production ready.

Download the code samples

You should always parse the returned link since special characters and white spaces will be automatically removed from the name of the uploaded file.