FIx Marcolin Problems
This commit is contained in:
@@ -95,6 +95,10 @@ namespace Step.Controllers.WebApi
|
||||
[Route("upload"), HttpPost]
|
||||
public async Task<IHttpActionResult> UpdloadProgramWithImage()
|
||||
{
|
||||
|
||||
bool imageUploaded = false;
|
||||
string mainPPName = "";
|
||||
|
||||
if (!Request.Content.IsMimeMultipartContent())
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
@@ -120,6 +124,8 @@ namespace Step.Controllers.WebApi
|
||||
if (item.ParameterName == "main")
|
||||
{
|
||||
File.WriteAllBytes(TEMP_PP_FOLDER + item.FileName, item.Data);
|
||||
mainPPName = item.FileName;
|
||||
|
||||
// Upload main program
|
||||
CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out ActiveProgramDataModel programData);
|
||||
if (cmsError.IsError())
|
||||
@@ -137,9 +143,23 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
// Upload image
|
||||
File.WriteAllBytes(PART_PRG_IMAGES + item.FileName, item.Data);
|
||||
imageUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!imageUploaded)
|
||||
{
|
||||
mainPPName = Path.GetFileNameWithoutExtension(mainPPName);
|
||||
string [] imgFiles = Directory.GetFiles(PART_PRG_IMAGES);
|
||||
foreach(string f in imgFiles)
|
||||
{
|
||||
if(Path.GetFileNameWithoutExtension(f) == mainPPName)
|
||||
File.Delete(f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Ok();
|
||||
|
||||
Reference in New Issue
Block a user