This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
@@ -194,7 +195,7 @@ namespace AyaNova.Api.Controllers
|
||||
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
|
||||
|
||||
var reportData = await biz.GetReportData(selectedRequest);
|
||||
if (reportData == null)
|
||||
@@ -321,7 +322,7 @@ namespace AyaNova.Api.Controllers
|
||||
[Authorize]
|
||||
[HttpPost("upload")]
|
||||
[DisableFormValueModelBinding]
|
||||
[RequestSizeLimit(15000000)]//currently the largest v7 export for a report template is 828kb, I'm guessing 15mb is more than enough
|
||||
[RequestSizeLimit(AyaNova.Util.ServerBootConfig.MAX_REPORT_TEMPLATE_UPLOAD_BYTES)]
|
||||
public async Task<IActionResult> UploadAsync()
|
||||
{
|
||||
//Adapted from the example found here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads#uploading-large-files-with-streaming
|
||||
@@ -337,10 +338,28 @@ namespace AyaNova.Api.Controllers
|
||||
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}"));
|
||||
|
||||
//Save uploads to disk under temporary file names until we decide how to handle them
|
||||
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
|
||||
|
||||
//Save uploads to disk under temporary file names until we decide how to handle them
|
||||
uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
|
||||
if (!string.IsNullOrWhiteSpace(uploadFormData.Error))
|
||||
{
|
||||
|
||||
|
||||
//delete temp files
|
||||
ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
|
||||
//file too large is most likely issue so in that case return this localized properly
|
||||
if (uploadFormData.Error.Contains("413"))
|
||||
{
|
||||
var TransId = UserTranslationIdFromContext.Id(HttpContext.Items);
|
||||
return BadRequest(new ApiErrorResponse(
|
||||
ApiErrorCode.VALIDATION_LENGTH_EXCEEDED,
|
||||
null,
|
||||
String.Format(await TranslationBiz.GetTranslationStaticAsync("AyaFileFileTooLarge", TransId, ct), AyaNova.Util.FileUtil.GetBytesReadable(AyaNova.Util.ServerBootConfig.MAX_REPORT_TEMPLATE_UPLOAD_BYTES))));
|
||||
}
|
||||
else//not too big, something else
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, uploadFormData.Error));
|
||||
}
|
||||
|
||||
List<UploadFileData> FileData = new List<UploadFileData>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user