1

I have an issue with azure-laravel streaming videos (video is slow and unable to seek). Saw a question in SO that this could be the x-ms-version causing it: here . I coulnd't find a way to fix to problem as described here:here .

I need to edit/specify my x-ms-version header. Where can I find the property x-ms-version in order to change it?

I found the file: vendor\microsoft\azure-storage\src\Common\Internal\Resources.php but I don't have a property called: STORAGE_API_LATEST_VERSION

UPDATE Image:

enter image description here

Any ideas, someone?

my media upload controller: (it works, I can upload the files)

 public function mediaUpload(Request $request)
{
    
    $fileName = time() . '_' . $request->file->getClientOriginalName();
    $url = $request->file('file')->storeAs($request->folder, $fileName, 'azure');

    if ($url) {
        $json = array(
            'uploaded' => true,
            'fileName' => basename($url),
            'fileNameFolder' => $url,
            'location' =>  $url,
        );

        return response()->json($json);
    }
}

My view file where I display the video:

  <div class="flex flex-wrap sm:w-7/12 mx-auto mt-10 relative z-10">
            <video id="player" playsinline controls :data-poster="$page.assetsUrl + video.thumbnail_path">
                <source :src="$page.assetsUrl + video.video_path" type="video/mp4" />
            </video>
        </div>

My BlobResources.php:

const BLOB_SDK_VERSION = '1.5.2';
const STORAGE_API_LATEST_VERSION = '2017-11-09';

HERE is a link to problematic video coming from azure blob storage:

brpetrov
  • 119
  • 2
  • 11

1 Answers1

1

1. Set the default service version to the latest version so that the behavior can be verified.

When using Azure Blob, the STORAGE_API_LATEST_VERSION is defined in "azure-storage-php-1.5.2-blob\azure-storage-blob\src\Blob\Internal\BlobResources.php" (latest version 1.5.2).

enter image description here


2. Change the version specified in the request.

You could using cURL with x-ms-version header to request Blob API.

Sample about getting Blob: https://stackoverflow.com/a/65002473/13308381

unknown
  • 6,778
  • 1
  • 5
  • 14
  • Hi @Pamela Peng. Thank you so much for answering that. One thing I am not sure about is: Where do I need to include the x-ms-version? I changed the STORAGE_API_LATEST_VERSION to '2020-04-08'. Do I need to also add it as a parameter on mu URI? like: https://myaccount.blob.core.windows.net/mycontainer/myblob?x-ms-version=2020-04-08 ? (sorry if that's a stupid question, I am not very familiar of how to achieve these). I have updated my question with an image that shows my x-ms-version:2009-09-19 – brpetrov Feb 03 '21 at 10:22
  • You don't need to add it to your storage URI. If using the [**SDK for PHP**](https://github.com/Azure/azure-storage-php), STORAGE_API_LATEST_VERSION should be changed. If you request the [**Blob service REST API**](https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api), you need to set the `x-ms-version` in Headers. That are two methods I mentioned. – unknown Feb 03 '21 at 12:14
  • Hi, my problem is that changing the STORAGE_API_LATEST_VERSION didn't help. My videos are still trying to fully download and cannot seek them on Chrome. I am not sure how to "set x-ms-version in headers". Do you have any code example for laravel? Where do I do that ( in controller/ View ?) I don't understand the MS article. (yes, I've never done that) – brpetrov Feb 03 '21 at 13:07
  • The SDK may not support the latest version, have you tried `2017-11-09` with the azure-storage-blob 1.5.2? – unknown Feb 03 '21 at 13:35
  • const BLOB_SDK_VERSION = '1.5.2'; const STORAGE_API_LATEST_VERSION = '2017-11-09'; – brpetrov Feb 03 '21 at 13:37
  • Could you share the code? I will try to reproduce it. – unknown Feb 03 '21 at 13:51
  • I've updated the question with my code and also an example link where you can see a problem with a video. Thank you!! Tell me if you need more – brpetrov Feb 03 '21 at 14:02
  • 1
    Sorry, I forgot to test your code. I'm not familiar with laravel, [Azure Storage SDK for PHP](https://azure.microsoft.com/en-us/blog/azure-storage-sdks-for-python-ruby-and-php-now-generally-available/) works. – unknown Feb 08 '21 at 12:24
  • Thanks, Pamela, I will give it a try. – brpetrov Feb 08 '21 at 13:02
  • Can you give me an example of how to use this SDK for Laravel? There is literally nothing on the web for these 2 – brpetrov Feb 09 '21 at 19:54
  • 1
    I made it work with the SDK, Thanks for everything – brpetrov Feb 10 '21 at 11:19