diff --git a/src/Alturos.Yolo.WebService/Communication/WebApi/ObjectDetectionController.cs b/src/Alturos.Yolo.WebService/Communication/WebApi/ObjectDetectionController.cs
index 6539b9a..1acfca1 100644
--- a/src/Alturos.Yolo.WebService/Communication/WebApi/ObjectDetectionController.cs
+++ b/src/Alturos.Yolo.WebService/Communication/WebApi/ObjectDetectionController.cs
@@ -1,6 +1,8 @@
using Alturos.Yolo.Model;
using Alturos.Yolo.WebService.Contract;
using System;
+using System.Net.Http;
+using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
@@ -37,6 +39,40 @@ public IHttpActionResult Detect(byte[] imageData)
}
}
+ ///
+ /// Upload image as multi-part from data
+ /// This example can be tested with pastman. http://localhost:8080//ObjectDetection//Upload
+ /// Select Body->form data
+ /// Then select "file" from the key box before typing in (any) key name. Then select your image file in the value.
+ ///
+ ///
+ [HttpPost]
+ [Route("Upload")]
+ [ResponseType(typeof(YoloItem[]))]
+ public async Task Detect()
+ {
+ // Get the HTTP request
+ //HttpRequestMessage httpRequest = this.Request;
+ var provider = new MultipartMemoryStreamProvider();
+ await Request.Content.ReadAsMultipartAsync(provider);
+
+ // Get the first value from the form
+ var file = provider.Contents[0];
+
+ // Read file as bytes
+ var imageData = await file.ReadAsByteArrayAsync();
+ try
+ {
+ // Pass byte array to wrapper
+ var items = this._objectDetection.Detect(imageData);
+ return Ok(items);
+ }
+ catch (Exception exception)
+ {
+ return InternalServerError(exception);
+ }
+ }
+
///
/// Detect object positions
///