Metodo uploadImage che richiede nome ricetta...
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
using CMS_CORE_Library.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using Thermo.Active.Config;
|
||||
using Thermo.Active.Model.DTOModels.ThRecipe;
|
||||
@@ -402,6 +407,33 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Route("uploadImage"), HttpPost]
|
||||
public async Task<IHttpActionResult> UpdloadImage()
|
||||
{
|
||||
bool imageUploaded = false;
|
||||
|
||||
if (!Request.Content.IsMimeMultipartContent())
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
}
|
||||
|
||||
List<FormItem> formItems = await MultipartHandler.ManageMultiPartFileAsync(Request);
|
||||
|
||||
foreach (FormItem item in formItems)
|
||||
{
|
||||
if (item.IsAFile)
|
||||
{
|
||||
if (item.ParameterName == "image" || item.MediaType.StartsWith"image/")
|
||||
{
|
||||
string filePath = item.FileName;
|
||||
imageUploaded = NcFileAdapter.SaveRecipeImage(item.FileName, item.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Do actual recipe parameters FileSave
|
||||
@@ -421,6 +453,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
ThermoActiveLogger.LogError($"Recipe | SaveCurrentRecipeParams exception | {exc}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// write current recipe to PLC
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user