Unverified Commit 7c1d6045 authored by Marius Göcke's avatar Marius Göcke
Browse files

+semver:minor

parent 70bd8aba
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ using GRYLibrary.Core.APIServer.Settings.Configuration;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SimpleOCR.Library.Core;
using SimpleOCR.Library.Core.FileTypes;
using SimpleOCR.Library.Core.Other;
using SimpleOCR.Service.Core.Constants;
using System.Collections.Generic;
@@ -30,23 +29,23 @@ namespace SimpleOCR.Service.Core.Controller
        [HttpPut]
        [Route(nameof(GetOCRContent))]
        [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
        public IActionResult GetOCRContent(IFormFile fileContent, [FromQuery] string fileType, [FromQuery] string[] languags)
        public IActionResult GetOCRContent(IFormFile fileContent, [FromQuery] string mimeType, [FromQuery] string[] languags)
        {
            using var ms = new MemoryStream();
            fileContent.CopyTo(ms);
            var fileContentAsByetArray = ms.ToArray();
            return this.Ok(_OCRService.GetOCRContent(fileContentAsByetArray, FileType.Deserialize(fileType), languags.ToHashSet()));
            return this.Ok(_OCRService.GetOCRContent(fileContentAsByetArray, mimeType, languags.ToHashSet()));
        }

        [HttpPut]
        [Route(nameof(ToPicture))]
        [ProducesResponseType(typeof(byte[]), StatusCodes.Status200OK)]
        public IActionResult ToPicture(IFormFile file, [FromQuery] string fileType, [FromQuery] string mimeType)
        public IActionResult ToPicture(IFormFile file, [FromQuery] string mimeType)
        {
            using var ms = new MemoryStream();
            file.CopyTo(ms);
            var fileContent = ms.ToArray();
            return this.Ok(_OCRService.ToPicture(fileContent, FileType.Deserialize(fileType), mimeType));
            return this.Ok(_OCRService.ToPicture(fileContent, mimeType));
        }

        [HttpPut]
+4 −5
Original line number Diff line number Diff line
using GRYLibrary.Core.APIServer.Settings;
using GRYLibrary.Core.Logging.GRYLogger;
using SimpleOCR.Library.Core;
using SimpleOCR.Library.Core.FileTypes;
using SimpleOCR.Library.Core.Other;
using System.Collections.Generic;
using System.IO;
@@ -30,11 +29,11 @@ namespace SimpleOCR.Service.Core.Services
            //nothing to do
        }

        public string GetOCRContent(byte[] fileContent, FileType fileType, ISet<string> languages)
        public string GetOCRContent(byte[] fileContent, string mimeType, ISet<string> languages)
        {
            try
            {
                return _OCRService.GetOCRContent(fileContent, fileType, languages);
                return _OCRService.GetOCRContent(fileContent, mimeType, languages);
            }
            catch
            {
@@ -62,9 +61,9 @@ namespace SimpleOCR.Service.Core.Services
            _OCRService.ReInitialize();
        }

        public byte[] ToPicture(byte[] fileContent, FileType fileType, string mimeType)
        public byte[] ToPicture(byte[] fileContent, string mimeType)
        {
            return _OCRService.ToPicture(fileContent, fileType, mimeType);
            return _OCRService.ToPicture(fileContent,  mimeType);
        }

    }
+1 −3
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ namespace SimpleOCR.Service.Tests.Testcases
            byte[] fileContent = TestUtilities.TestUtilities.LoadResourceFileContent($"Test.png");
            formFileMock.Setup(formFile => formFile.CopyTo(It.IsAny<Stream>())).Callback<Stream>((stream) => stream.Write(fileContent, 0, fileContent.Length));
            SimpleOCRController simpleOCRController = new SimpleOCRController(ocrService);
            string expectedOutput = SimpleOCR.Library.Core.Misc.Utilities.NormalizeString(@"Test1

Test2");
            string expectedOutput = "Test1\nTest2";
            var languages = new string[] { "eng" };
            string fileTypeAsString =FileType.Serialize( Picture.Instance);