Пример #1
0
# Provide the path to a local testfile, that can be uploaded via RASS
define('LOCAL_FILE', '/path/to/local/file');
# add path to local (video) file, to be uploaded to the CDN
# Provide your own RASS credentials here
define('USER', 'xxx');
# your user account name
define('PWD', 'xxx');
# your user account pwd
define('RASS_SERVER', 'rass.cdn0x.rambla.be');
# either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
# all RASS API methods (except HEAD) will raise an exception if they don't return an HTTP SUCCESS CODE (200,201,204)
try {
    # Instantiate an object that manages the RASS connection, passing it your login credentials and the base service uri
    $rass = new RassService(USER, PWD, RASS_SERVER);
    # Creates a "tutorial2" directory below your root dir
    $dir = $rass->createDir("tutorial2");
    # Retrieve the entry's "path" param
    echo "Created directory with path: " . $dir->entry->content->params->path . "\n";
    # Note: the URL for accessing this new dir resource is available as the entry's id
    echo "New dir resource can be accessed at the URL: " . $dir->entry->id . "\n";
    # Uploads the local file as 'taste.mp4' to the "tutorial2" directory on the CDN
    $item = $rass->createItem($dir->entry->content->params->path, "taste.mp4", LOCAL_FILE);
    # Retrieve the entry's "path" attribute
    echo "\nCreated file with path: " . $item->entry->content->params->path . "\n";
    # Retrieve the filename on the CDN
    echo "Filename: " . $item->entry->content->params->filename . "\n";
    # Get the location of the file on the CDN from the entry's 'enclosure' link
    echo "Public download location of the uploaded file: " . $rass->getEnclosureLink($item) . "\n";
    # Note: the URL for accessing this new item resource is available as the entry's id
    echo "New dir resource can be accessed at the URL: " . $item->entry->id . "\n";
    # PUT the same file for a second time => RASS will add a numerical suffix
define('RASS_SERVER', 'rass.cdn0x.rambla.be');
# either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
# all RASS API methods (except HEAD) will raise an exception if they don't return an HTTP SUCCESS CODE (200,201,204)
try {
    # Instantiate an object that manages the RASS connection, passing it your login credentials and the base service uri
    $rass = new RassService(USER, PWD, RASS_SERVER);
    # Upload the local file as 'testX.mp4' to the CDN (= account's root-directory)
    $items = array();
    $ctr = 1;
    while ($ctr < 3) {
        $items[] = $item = $rass->createItem("/", "test{$ctr}.mp4", LOCAL_FILE);
        echo "Created file with path: " . $item->entry->content->params->path . "\n";
        $ctr += 1;
    }
    # Create a "bucks" directory under the root-directory
    $dir = $rass->createDir("bucks", True);
    echo "Created directory with path: " . $dir->entry->content->params->path . "\n";
    $ctr = 1;
    # Upload the local file as 'bunnyX.mp4' to the "bucks" directory
    while ($ctr < 3) {
        $item = $rass->createItem($dir->entry->content->params->path, "bunny{$ctr}.mp4", LOCAL_FILE);
        echo "Created file with path: " . $item->entry->content->params->path . "\n";
        $ctr += 1;
    }
    # Retrieve a list of the files inside our root-directory
    echo "\nGetting files located under the root-directory:\n";
    $dir_feed = $rass->getDirList("/", "kind=file");
    # Walk through the list of entries (entry == file)
    foreach ($dir_feed->feed->entry as $entry) {
        # Retrieve the entry element's "kind" and "path" attributes
        echo "\nFound " . $entry->content->params->kind . " entry with path = " . $entry->content->params->path . "\n";
# add path to local (video) file, to be uploaded to the CDN
# Provide your own RASS credentials here
define('USER', 'xxx');
# your user account name
define('PWD', 'xxx');
# your user account pwd
define('RASS_SERVER', 'rass.cdn0x.rambla.be');
# either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
# all RASS API methods (except HEAD) will raise an exception if they don't return an HTTP SUCCESS CODE (200,201,204)
try {
    # Instantiate an object that manages the RASS connection, passing it your login credentials and the base service uri
    $rass = new RassService(USER, PWD, RASS_SERVER);
    ## TUTORIAL PRE-CONFIG: FIRST CREATE DIRECTORY + UPLOAD FILES TO HAVE SOME TEST-DATA
    # Create a "tutorial6" directory under the root-directory
    $item = null;
    $dir = $rass->createDir("tutorial6", True);
    echo "Created directory with path: " . $dir->entry->content->params->path . "\n";
    $ctr = 1;
    # Upload the local file 15 times as 'testXX.mp4' to the "tutorial6" directory (creating some test data)
    while ($ctr < 16) {
        $item = $rass->createItem($dir->entry->content->params->path, "test{$ctr}.mp4", LOCAL_FILE);
        echo "Created file with path: " . $item->entry->content->params->path . "\n";
        $ctr += 1;
    }
    ## GETTING LINK ELEMENTS FOR AN ENTRY
    # Directly getting at an item entry's link elements
    echo "\nGetting all link elements for entry with path: " . $item->entry->content->params->path . "\n";
    foreach ($item->entry->link as $link) {
        echo "\nType of relation: " . $link->rel;
        echo "\nLink URI: " . $link->href;
        echo "\nExpected type: " . $link->type . "\n";
Пример #4
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# To run this sample, define these variables first
define('USER', "xxx");
# name of your Rambla user account
define('PWD', "xxx;;");
# password of your Rambla user account
define('RASS_SERVER', 'rass.cdnXX.rambla.be');
# either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located)
require_once 'raws_json/json_client.php';
require_once 'raws_json/rass_service.php';
try {
    $rass = new RassService(USER, PWD, RASS_SERVER);
    # create dir on CDN
    $dir = $rass->createDir("/test/sample/dir", True);
    echo "\nCreated dir: " . $dir->entry->id . "\n";
    # retrieve feed of dirs
    echo "\nGetting dir list...";
    $feed = $rass->getDirList("/test/");
    foreach ($feed->feed->entry as $e) {
        echo "\n* retrieved dir: " . $e->id . " with size = " . $e->content->params->size;
    }
    echo "\n... finished retrieving dir instances.\n";
    # delete file from cdn
    $rass->deleteDir($dir->entry->content->params->path);
    echo "\nDeleted dir with path = " . $dir->entry->content->params->path . "\n";
} catch (Exception $e) {
    echo "\nAn exception occurred with code = " . $e->getCode();
    echo "\nError msg = " . $e->getMessage();
}