Saturday, August 5, 2017

HTML5 Video hosted in Azure Storage

If you are like me and hosting Video files (MPEG / WEBM / OGG) in Azure Storage, you will probably need to do the following so that the MIME type comes down correctly:

        public static CloudBlockBlob UploadAndSaveBlob(CloudBlobContainer blobContainer, String text, String contentType, String extension)
            string blobName = Guid.NewGuid().ToString() + extension;
            // Retrieve reference to a blob. 
            CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobName);
            // Create the blob by uploading a local file.
            // Set the Blob content type
            blob.Properties.ContentType = contentType;

            logger.Info(String.Format("Uploaded text file to {0}", blob.Uri));

            return blob;

and call the method, passing in a contentType of "video/mp4" for example.

This will set a ContentType Property on your Blob.

Also, you will probably need to install a WebM plugin for IE (which is oddly enough put out by Google, nice to see they're looking out for IE).

No comments:

Post a Comment