All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 1m8s
Mindforge Cronjob Build and Deploy / Build Mindforge Cronjob Image (push) Successful in 1m19s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 11s
Mindforge Cronjob Build and Deploy / Deploy Mindforge Cronjob (internal) (push) Successful in 10s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 2m25s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 12s
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Mindforge.API.Exceptions;
|
|
using Mindforge.API.Models.Requests;
|
|
using Mindforge.API.Services.Interfaces;
|
|
|
|
namespace Mindforge.API.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/v1/file")]
|
|
public class FileController : ControllerBase
|
|
{
|
|
private readonly IFileService _fileService;
|
|
|
|
public FileController(IFileService fileService)
|
|
{
|
|
_fileService = fileService;
|
|
}
|
|
|
|
[HttpPost("check")]
|
|
public async Task<IActionResult> CheckFile([FromBody] FileCheckRequest request)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(request.FileContent) || string.IsNullOrWhiteSpace(request.CheckType))
|
|
{
|
|
throw new UserException("FileContent and CheckType are required.");
|
|
}
|
|
|
|
try
|
|
{
|
|
var base64Bytes = Convert.FromBase64String(request.FileContent);
|
|
request.FileContent = System.Text.Encoding.UTF8.GetString(base64Bytes);
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
throw new UserException("FileContent must be a valid base64 string.");
|
|
}
|
|
|
|
var response = await _fileService.CheckFileAsync(request);
|
|
return Ok(new { result = response });
|
|
}
|
|
}
|
|
}
|