10940

Uploading video to Azure Storage through Xamarin

Question:

I'm trying to upload a video file to my Azure Storage account. I've got it working with images, however trying to view an uploaded video gives the message "Video format or MIME-type is not supported". The video format is mp4.

I use the following code to upload:

public async Task UploadVideo(Stream video, string path) { var container = GetContainer("videos"); // Creates the container if it does not exist await CreateContainer(container); //Gets the file extension string lastPart = path.Split('.').Last(); // Uploads the video to the blob storage CloudBlockBlob videoBlob = container.GetBlockBlobReference(path); videoBlob.Properties.ContentType = "video/" + lastPart; await videoBlob.UploadFromStreamAsync(video); }

Am I doing something wrong?

Thanks

Edit:

Here's the code I use to capture video on the phone:

private async Task TakeVideoButton_Clicked(object sender, EventArgs e) { if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported) { await DisplayAlert("No Camera", ":( No camera avaialble.", "OK"); return; } mediaFile = await CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions { Name = "video.mp4", Directory = "DefaultVideos", }); if (mediaFile == null) return; await DisplayAlert("Video Recorded", "Location: " + mediaFile.Path, "OK"); videoStream = mediaFile.GetStream(); file.Dispose(); }

Answer1:

I just tested this on my phone instead of my emulator and it worked perfectly there, so I'm going to assume it's purely a emulator related issue.

Recommend

  • Issue with the Entity Manager and phpunit in Symfony 2
  • How can I use the getContainer() in my self-made service
  • Draw border edges of the Konvajs container Stage in html
  • MEF parts list sometimes empty
  • GData Youtube : obtaining thumbnails
  • Get Users in Group from Azure AD via Microsoft Graph
  • Youtube upload API and cordova / phonegap
  • Unable to hide youtube iframes in safari?
  • Unzip archive in .Net CORE 1.0
  • Streaming screenshots over WebRTC as a video stream from iOS
  • What Makes These Two Array Adds Different?
  • Authentication failed with Azure Active Directory in Windows Phone
  • C#: Import/Export Settings into/from a File
  • Syntax error on tokens, AnnotationName expected instead - error on query
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • Bigquery event streaming and table creation
  • ThreadStatic in asynchronous ASP.NET Web API
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • How can I display the parent menu item's description using Wordpress walkers?
  • Cannot upload to OneDrive using the new SDK
  • Xcode 4 NSLog Macro link in Xcode 3
  • Play WS (2.2.1): post/put large request
  • Bad request using file_get_contents for PUT request in PHP
  • Allowing both email and username for authentication
  • Change Inet root folder for iis 7
  • swift auto completion not working in Xcode6-Beta
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • AT Commands to Send SMS not working in Windows 8.1
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to delete a row from a dynamic generate table using jquery?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • using HTMLImports.whenReady not working in chrome
  • File not found error Google Drive API
  • Qt: Run a script BEFORE make
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • EntityFramework adding new object to nested object collection
  • Sorting a 2D array using the second column C++