Streaming video from Azure blob storage

前端 未结 1 438
离开以前
离开以前 2021-01-13 14:08

I\'m having problems getting an .mp4 video stored in Azure blob storage to show in a website hosted on Azure. The video type is set to video/mp4, t

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 14:48

    Based on your comments above, what you need is a Shared Access Signature. Use the code below to create a shared access signature on your mp4 file.

            var credentials = new StorageCredentials("myaccountname", "mysecretkey");
            var account = new CloudStorageAccount(credentials, true);
            var container = account.CreateCloudBlobClient().GetContainerReference("yourcontainername");
            var blob = container.GetBlockBlobReference("yourmp4filename");
            var sas = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
            {
                Permissions = SharedAccessBlobPermissions.Read,
                SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),//Set this date/time according to your requirements
            });
            var urlToBePlayed = string.Format("{0}{1}", blob.Uri, sas);//This is the URI which should be embedded in your video player.
    

    0 讨论(0)
提交回复
热议问题