I have an issue with azure storage blob is not returning 206 Partial content for video files.
Problem: videos are fully downloaded(20-40s for 300mb videos) and the seek bar is not working. I am using Laravel and this problem occurs only when I try to retrieve the .mp4 files from Azure Blob Storage. It was working fine when I was storing the media files on the public disk.
A microsoft employee states that changing the x-ms-version to 2011-01-18 or later will fix my issue. LINK to the discussion:
Microsoft have a post related to setting the blob servic properties: HERE
Note their sample for achieving that: https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties#sample-request-and-response
I am trying to send the request via Postman like this:
PUT https://{account-name}.blob.core.windows.net/?restype=service&comp=properties
Included Headers and Response in Postman:
I searched for the error and found this question on SO: The MAC signature found in the HTTP request '...' is not the same as any computed signature
It has an accepted answer but I don't seem to get it. Is there something wrong with my Request/ Authorization header? Or I need to take a different approach?
Thanks in advance!
My code in LARAVEL:
$date = gmdate('D, d M Y H:i:s \G\M\T');
$account_name = "xyz";
$containername = "media";
$account_key = "access_key";
$canonicalizedHeaders = "x-ms-date:$date\nx-ms-version:2017-11-09";
$canonicalizedResource = "/$account_name/$containername\ncomp:list\nrestype:container";
$arraysign = array();
$arraysign[] = 'GET'; /*HTTP Verb*/
$arraysign[] = ''; /*Content-Encoding*/
$arraysign[] = ''; /*Content-Language*/
$arraysign[] = ''; /*Content-Length (include value when zero)*/
$arraysign[] = ''; /*Content-MD5*/
$arraysign[] = ''; /*Content-Type*/
$arraysign[] = ''; /*Date*/
$arraysign[] = ''; /*If-Modified-Since */
$arraysign[] = ''; /*If-Match*/
$arraysign[] = ''; /*If-None-Match*/
$arraysign[] = ''; /*If-Unmodified-Since*/
$arraysign[] = ''; /*Range*/
$arraysign[] = $canonicalizedHeaders; /*CanonicalizedHeaders*/
$arraysign[] = $canonicalizedResource; /*CanonicalizedResource*/
$stringtosign = implode("\n", $arraysign);
$signature = 'SharedKey' . ' ' . $account_name . ':' . base64_encode(hash_hmac('sha256', $stringtosign, base64_decode($account_key), true));
$endpoint = 'https://' . $account_name . '.blob.core.windows.net';
$url = $endpoint . '/' . $containername . '?restype=container';
$headers = [
"x-ms-date:{$date}",
'x-ms-version:2017-11-09',
'Accept:application/json;odata=nometadata',
"Authorization:{$signature}"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
echo '<pre>';
print_r($response);