From 57d3d748565a6a3221a2c1c1434b15c4deb834a1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 16 May 2013 22:32:23 -0400 Subject: [PATCH] fixed ie10 image uploading --- MediaBrowser.Api/Images/ImageService.cs | 13 ++++++++++++- MediaBrowser.Api/MediaBrowser.Api.csproj | 1 + MediaBrowser.WebDashboard/Api/DashboardService.cs | 2 +- MediaBrowser.WebDashboard/ApiClient.js | 10 ++++++---- MediaBrowser.WebDashboard/packages.config | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 081ba5612..3f5b9da2a 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Common.Configuration; +using System.Drawing; +using System.Text; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; @@ -717,6 +719,15 @@ namespace MediaBrowser.Api.Images var bytes = Convert.FromBase64String(text); + // Validate first + using (var memoryStream = new MemoryStream(bytes)) + { + using (var image = Image.FromStream(memoryStream)) + { + Logger.Info("New image is {0}x{1}", image.Width, image.Height); + } + } + string filename; switch (imageType) diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index d300fe19c..2819a649a 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -55,6 +55,7 @@ + diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 683ecda97..d4a4fb708 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -385,7 +385,7 @@ namespace MediaBrowser.WebDashboard.Api sb.Append(""); sb.Append(""); - sb.Append(""); + //sb.Append(""); // http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html sb.Append(""); diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index 1c5c6339a..a46fe3487 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -922,7 +922,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { // Closure to capture the file information. reader.onload = function (e) { - var data = window.btoa(e.target.result); + // Split by a comma to remove the url: prefix + var data = e.target.result.split(',')[1]; var url = self.getUrl("Users/" + userId + "/Images/" + imageType); @@ -941,7 +942,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }; // Read in the image file as a data URL. - reader.readAsBinaryString(file); + reader.readAsDataURL(file); return deferred.promise(); }; @@ -979,7 +980,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { // Closure to capture the file information. reader.onload = function (e) { - var data = window.btoa(e.target.result); + // Split by a comma to remove the url: prefix + var data = e.target.result.split(',')[1]; var url = self.getUrl("Items/" + itemId + "/Images/" + imageType); @@ -998,7 +1000,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }; // Read in the image file as a data URL. - reader.readAsBinaryString(file); + reader.readAsDataURL(file); return deferred.promise(); }; diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index 18aa38dd6..8420a4504 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file