Add remaining project files

This commit is contained in:
Marco Baldwin
2026-07-23 18:21:43 -07:00
parent c12d8ac35d
commit 6e15e89a9d
453 changed files with 64265 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
using DeluxeBackend.Models;
using DeluxeBackend.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel.DataAnnotations;
using static DeluxeBackend.Enums;
namespace DeluxeBackend.Controllers
{
[Route("Storage")]
[ApiController]
public class StorageController(IJwtService jwt, ILiteDbService db, ICdnService cdn) : ControllerBase
{
[HttpPost("upload")]
[Authorize(Roles = "gameClient")]
public async Task<IActionResult> Upload([FromForm(Name = "FileType"), Required] FileType fileType, [FromForm(Name = "File"), Required] IFormFile file)
{
Account? account = await jwt.GetLogin(User);
if (account == null)
{
return Unauthorized();
}
string path = "fuck";
switch (fileType)
{
case FileType.Image:
path = "img";
break;
case FileType.Holotar:
path = "data";
break;
case FileType.SubRoomSave:
path = "room";
break;
case FileType.RoomMetadata:
path = "room";
break;
case FileType.Invention:
path = "invention";
break;
default:
return BadRequest();
}
using var stream = file.OpenReadStream();
var (remotePath, proof) = await cdn.UploadFile(
stream,
path,
account
);
if (remotePath == null)
{
return StatusCode(500, $"Failed to upload {fileType} to the CDN.");
}
return Ok(new
{
Filename = remotePath,
Hash = "meow",
OwnershipProof = proof
});
}
}
}