Skip to content

Instantly share code, notes, and snippets.

@dkarlovi
Created May 18, 2016 12:19
Show Gist options
  • Save dkarlovi/02421f15889e1e475f3fa191c71d0030 to your computer and use it in GitHub Desktop.
Save dkarlovi/02421f15889e1e475f3fa191c71d0030 to your computer and use it in GitHub Desktop.
<?php
use WindowsAzure\Blob\Models\ContainerAcl;
use WindowsAzure\Blob\Models\PublicAccessType;
// after having run a Job to create a thumbnail from our uploaded media item as seen:
// http://stackoverflow.com/questions/31070909/how-to-get-a-thumbnail-from-a-video-on-azure-media-services
// this asset contains our thumbnails
$asset = current($mediaServicesProxy->getJobOutputMediaAssets($job));
// HACK: this extracts only the asset name (which is a storage container)
$container = trim(parse_url($asset->getUri(), PHP_URL_PATH), '/');
$acl = new ContainerAcl();
$acl->setPublicAccess(PublicAccessType::BLOBS_ONLY);
// a blob storage REST proxy is created as seen here
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
$blobRestProxy->setContainerAcl($container, $acl);
// give Azure time to propagate the ACL
sleep(5);
$urls = [];
$files = $mediaServicesProxy->getAssetAssetFileList($asset);
foreach ($files as $file) {
if ('xml' !== strtolower(pathinfo($file->getName(), PATHINFO_EXTENSION))) {
// HACK: create the complete URL of the thumbnail
// note that you use your Blob Storage account here, NOT your Media Services account
$urls[] = 'https://<Azure Blob Storage Account>.blob.core.windows.net/'.$container.'/'.rawurlencode($file->getName());
}
}
print_r($urls);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment