Skip to content

Commit

Permalink
fix get_stream_url for abs asset_name
Browse files Browse the repository at this point in the history
  • Loading branch information
sebest committed Sep 12, 2012
1 parent e613975 commit 00f4c0a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions CloudKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function get_stream_url($args)
$protocol = null;
extract($args);
if (!in_array($protocol, array(null, "hls", "rtmp", "hps", "http", "hds", "ss"))) {
throw new CloudKey_InvalidMethodException(sprintf('%s is not a valid streaming protocol', $protocol));
throw new CloudKey_InvalidParamException(sprintf('%s is not a valid streaming protocol', $protocol));
}
if ($extension == '')
{
Expand All @@ -120,18 +120,27 @@ public function get_stream_url($args)
{
return sprintf('http://static.dmcloud.net/%s/%s/%s%s.%s', $this->user_id, $id, $asset_name, $version, $extension);
}
else

if ($download or $filename)
{
if ($download or $filename) {
$protocol = 'http';
}
$url = sprintf('%s/route%s/%s/%s/%s%s%s', $this->cdn_url, $protocol ? "/$protocol" : '', $this->user_id, $id, $asset_name, $version, $extension != '' ? ".$extension" : '');
if ($filename)
$protocol = 'http';
}

if ($asset_name == 'abs')
{
$extension = '';
if ($protocol == null)
{
$url = sprintf('%s?filename=%s', $url, urlencode(utf8_encode($filename)));
throw new CloudKey_InvalidParamException('protocol is required for abs asset_name');
}
return CloudKey_Helpers::sign_url($url, $this->api_key, $seclevel, $asnum, $ip, $useragent, $countries, $referers, $expires);
}

$url = sprintf('%s/route%s/%s/%s/%s%s%s', $this->cdn_url, $protocol ? "/$protocol" : '', $this->user_id, $id, $asset_name, $version, $extension != '' ? ".$extension" : '');
if ($filename)
{
$url = sprintf('%s?filename=%s', $url, urlencode(utf8_encode($filename)));
}
return CloudKey_Helpers::sign_url($url, $this->api_key, $seclevel, $asnum, $ip, $useragent, $countries, $referers, $expires);
}
}

Expand Down

0 comments on commit 00f4c0a

Please sign in to comment.