Created
May 18, 2016 12:19
-
-
Save dkarlovi/02421f15889e1e475f3fa191c71d0030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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