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"; # 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");
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"; echo "Last link URI: " . $rass->getLastLink($dir_list) . "\n"; # There's also a helper function to directly get at the 'next' feed (takes the original feed as argument) $next_list = $rass->getNextList($dir_list);
# 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(); }