Browse Source

fixed ie10 image uploading

Luke Pulverenti 12 years ago
parent
commit
57d3d74856

+ 12 - 1
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.Extensions;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
@@ -717,6 +719,15 @@ namespace MediaBrowser.Api.Images
 
 
                 var bytes = Convert.FromBase64String(text);
                 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;
                 string filename;
 
 
                 switch (imageType)
                 switch (imageType)

+ 1 - 0
MediaBrowser.Api/MediaBrowser.Api.csproj

@@ -55,6 +55,7 @@
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.XML" />
     <Reference Include="System.XML" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 1 - 1
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -385,7 +385,7 @@ namespace MediaBrowser.WebDashboard.Api
 
 
             sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">");
             sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">");
             sb.Append("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">");
             sb.Append("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">");
-            sb.Append("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\">");
+            //sb.Append("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\">");
 
 
             // http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
             // http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
             sb.Append("<link rel=\"apple-touch-icon\" href=\"css/images/touchicon.png\" />");
             sb.Append("<link rel=\"apple-touch-icon\" href=\"css/images/touchicon.png\" />");

+ 6 - 4
MediaBrowser.WebDashboard/ApiClient.js

@@ -922,7 +922,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
             // Closure to capture the file information.
             // Closure to capture the file information.
             reader.onload = function (e) {
             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);
                 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.
             // Read in the image file as a data URL.
-            reader.readAsBinaryString(file);
+            reader.readAsDataURL(file);
 
 
             return deferred.promise();
             return deferred.promise();
         };
         };
@@ -979,7 +980,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
             // Closure to capture the file information.
             // Closure to capture the file information.
             reader.onload = function (e) {
             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);
                 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.
             // Read in the image file as a data URL.
-            reader.readAsBinaryString(file);
+            reader.readAsDataURL(file);
 
 
             return deferred.promise();
             return deferred.promise();
         };
         };

+ 1 - 1
MediaBrowser.WebDashboard/packages.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
 <packages>
-  <package id="MediaBrowser.ApiClient.Javascript" version="3.0.114" targetFramework="net45" />
+  <package id="MediaBrowser.ApiClient.Javascript" version="3.0.115" targetFramework="net45" />
   <package id="ServiceStack.Common" version="3.9.45" targetFramework="net45" />
   <package id="ServiceStack.Common" version="3.9.45" targetFramework="net45" />
   <package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" />
   <package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" />
 </packages>
 </packages>