This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -51,7 +51,7 @@
|
|||||||
"AYANOVA_USE_URLS": "http://*:7575;",
|
"AYANOVA_USE_URLS": "http://*:7575;",
|
||||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||||
"AYANOVA_SERVER_TEST_MODE":"true",
|
"AYANOVA_SERVER_TEST_MODE":"false",
|
||||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small",
|
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL":"small",
|
||||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET":"-7",
|
||||||
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
"AYANOVA_BACKUP_PG_DUMP_PATH":"C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\"
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[ApiVersion("8.0")]
|
[ApiVersion("8.0")]
|
||||||
[Route("api/v{version:apiVersion}/Logo")]
|
[Route("api/v{version:apiVersion}/logo")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class LogoController : ControllerBase
|
public class LogoController : ControllerBase
|
||||||
@@ -115,14 +115,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// Max 500 KiB total (512000 bytes)
|
/// Max 500 KiB total (512000 bytes)
|
||||||
/// Must have full rights to Global object
|
/// Must have full rights to Global object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="size">One of "small", "medium", "large"</param>
|
/// <param name="size">One of "small", "medium", "large"</param>
|
||||||
/// <param name="uploadFile">Logo image file</param>
|
|
||||||
/// <returns>Accepted</returns>
|
/// <returns>Accepted</returns>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost("{size}")]
|
[HttpPost("{size}")]
|
||||||
[DisableFormValueModelBinding]
|
//[DisableFormValueModelBinding]
|
||||||
[RequestSizeLimit(MAXIMUM_LOGO_SIZE)]//currently export file is 200kb * 50 maximum at a time = 15mb https://github.com/aspnet/Announcements/issues/267
|
[RequestSizeLimit(MAXIMUM_LOGO_SIZE)]//currently export file is 200kb * 50 maximum at a time = 15mb https://github.com/aspnet/Announcements/issues/267
|
||||||
public async Task<IActionResult> UploadAsync([FromRoute] string size, IFormFile uploadFile)
|
public async Task<IActionResult> UploadAsync([FromRoute] string size)//, List<IFormFile> files /// <param name="files">Logo image file</param>
|
||||||
{
|
{
|
||||||
|
|
||||||
//https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-3.1#upload-small-files-with-buffered-model-binding-to-a-database
|
//https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-3.1#upload-small-files-with-buffered-model-binding-to-a-database
|
||||||
@@ -148,24 +147,28 @@ namespace AyaNova.Api.Controllers
|
|||||||
ct.Logo.Add(logo);
|
ct.Logo.Add(logo);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var file = Request.Form.Files[0];
|
||||||
|
|
||||||
|
//var file=files[0];
|
||||||
using (var memoryStream = new MemoryStream())
|
using (var memoryStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
await uploadFile.CopyToAsync(memoryStream);
|
await file.CopyToAsync(memoryStream);
|
||||||
if (memoryStream.Length < 2097152)
|
if (memoryStream.Length > MAXIMUM_LOGO_SIZE)
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, null, "Logo files must be smaller than 500KiB maximum"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, null, $"Logo files must be smaller than {MAXIMUM_LOGO_SIZE} maximum"));
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
case "small":
|
case "small":
|
||||||
logo.Small = memoryStream.ToArray();
|
logo.Small = memoryStream.ToArray();
|
||||||
logo.SmallType = uploadFile.ContentType;
|
logo.SmallType = file.ContentType;
|
||||||
break;
|
break;
|
||||||
case "medium":
|
case "medium":
|
||||||
logo.Medium = memoryStream.ToArray();
|
logo.Medium = memoryStream.ToArray();
|
||||||
logo.MediumType = uploadFile.ContentType;
|
logo.MediumType = file.ContentType;
|
||||||
break;
|
break;
|
||||||
case "large":
|
case "large":
|
||||||
logo.Large = memoryStream.ToArray();
|
logo.Large = memoryStream.ToArray();
|
||||||
logo.LargeType = uploadFile.ContentType;
|
logo.LargeType = file.ContentType;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user