[MediaContent] Add missing description and its related code (#788)
authorhsgwon <haesu.gwon@samsung.com>
Fri, 12 Apr 2019 09:28:20 +0000 (18:28 +0900)
committerGitHub <noreply@github.com>
Fri, 12 Apr 2019 09:28:20 +0000 (18:28 +0900)
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaInfoCommand.cs

index 9b9f6be..3a820bf 100644 (file)
@@ -954,6 +954,7 @@ namespace Tizen.Content.MediaContent
         /// </summary>
         /// <remarks>
         ///     Media in the external storage is not supported, with the exception of MMC.
+        ///     Only JPEG, PNG, BMP images are supported.
         /// </remarks>
         /// <privilege>http://tizen.org/privilege/content.write</privilege>
         /// <feature>http://tizen.org/feature/vision.face_recognition</feature>
@@ -1018,6 +1019,14 @@ namespace Tizen.Content.MediaContent
                     throw new UnsupportedContentException("Only image is supported.");
                 }
 
+                // Native P/Invoke function also check below case, but it returns invalid operation error.
+                // So we check it here to throw more proper exception.
+                string mimeType = InteropHelper.GetString(handle, Interop.MediaInfo.GetMimeType);
+                if (!mimeType.Equals("image/jpeg") && !mimeType.Equals("image/png") && !mimeType.Equals("image/bmp"))
+                {
+                    throw new UnsupportedContentException($"{mimeType} is not supported. Only JPEG, PNG, BMP is supported.");
+                }
+
                 var path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
 
                 if (File.Exists(path) == false)