# 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"; } # Using a helper method to get to an entry's enclosure URL echo "\nGetting enclosure link (= download location of the file on the CDN) via helper method: " . $rass->getEnclosureLink($item) . "\n"; ## GETTING LINK ELEMENTS FOR A FEED # Retrieve a list of the files inside the 'tutorial6' sub-directory $dir_list = $rass->getDirList($dir->entry->content->params->path, "kind=file"); # Directly getting at the item entry's link elements echo "\nGetting all link elements for feed with ID: " . $dir_list->feed->id . "\n"; foreach ($dir_list->feed->link as $link) { echo "\nType of relation: " . $link->rel; echo "\nLink URI: " . $link->href; echo "\nExpected type: " . $link->type . "\n"; } ## USING PAGINATION (via helper functions) # Since we've uploaded 15 files, we can retrieve partial results by suggesting to RASS that we only want 10 results in a single response $dir_list = $rass->getDirList($dir->entry->content->params->path, "kind=file;paginate_by=10"); # since the request only contains 10 entries, there should be a 'next' + 'last' link inside the feed element echo "\nNext link URI: " . $rass->getNextLink($dir_list) . "\n";
# 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 $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"; # DELETE file on the CDN $rass->deleteItem($item->entry->content->params->path); echo "\nDeleted file: " . $item->entry->content->params->path . "\n";
$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"; # Retrieve the value of some file properties echo "Filename: " . $entry->content->params->filename . "\n"; echo "Filesize: " . $entry->content->params->size . "\n"; # Retrieve the public URL of the file (for download by end-users from the CDN) echo "Download URL: " . $rass->getEnclosureLink($entry) . "\n"; # Retrieve URL at which we can access the item resource (= wraps a file) using RASS echo "Entry ID: " . $entry->id . "\n"; } # Retrieve a list of the files inside the 'bucks' sub-directory echo "\nGetting files located under 'bucks' sub-directory:\n"; $dir_feed = $rass->getDirList("/bucks", "kind=file"); foreach ($dir_feed->feed->entry as $entry) { echo "\nFound " . $entry->content->params->kind . " entry with path = " . $entry->content->params->path . "\n"; echo "Filename: " . $entry->content->params->filename . "\n"; echo "Filesize: " . $entry->content->params->size . "\n"; echo "Download URL: " . $rass->getEnclosureLink($entry) . "\n"; echo "Entry ID: " . $entry->id . "\n"; } # Retrieve a list of sub-directories of our root directory echo "\nGetting sub-directories of the root-direcory:\n";