Rework Profile Picture Storage

This commit is contained in:
Alan Moon 2025-06-21 13:13:02 -07:00
parent df48a1491f
commit 957c3843d1
3 changed files with 8 additions and 4 deletions

View File

@ -32,7 +32,7 @@ namespace qtc_api.Controllers
public async Task<ActionResult<ServiceResponse<Room>>> DeleteRoom(string roomId) public async Task<ActionResult<ServiceResponse<Room>>> DeleteRoom(string roomId)
{ {
var response = await _roomService.DeleteRoom(roomId); var response = await _roomService.DeleteRoom(roomId);
await _hubContext.Clients.All.SendAsync("cf", "rul"); await _hubContext.Clients.All.SendAsync("cf", "rr");
return Ok(response); return Ok(response);
} }

View File

@ -249,8 +249,8 @@
if (!Directory.Exists(cdnPath)) Directory.CreateDirectory(cdnPath!); if (!Directory.Exists(cdnPath)) Directory.CreateDirectory(cdnPath!);
if (!Directory.Exists($"{cdnPath}/{userId}")) Directory.CreateDirectory($"{cdnPath}/{userId}"); if (!Directory.Exists($"{cdnPath}/{userId}")) Directory.CreateDirectory($"{cdnPath}/{userId}");
var fileName = $"{userId}.{file.FileName.Split('.')[1]}"; var fileName = $"{userId}.pfp";
var filePath = Path.Combine(cdnPath!, userId, fileName); var filePath = Path.Combine(cdnPath ?? "./user-content", userId, fileName);
using (var stream = File.Create(filePath)) using (var stream = File.Create(filePath))
{ {
@ -303,7 +303,7 @@
serviceResponse.Success = true; serviceResponse.Success = true;
serviceResponse.Message = user.ProfilePicture; serviceResponse.Message = user.ProfilePicture;
serviceResponse.Data = new FileContentResult(File.ReadAllBytes(pic), $"image/{Path.GetExtension(pic)}"); serviceResponse.Data = new FileContentResult(File.ReadAllBytes(pic), "image/jpeg");
} else } else
{ {
serviceResponse.Success = false; serviceResponse.Success = false;

View File

@ -34,4 +34,8 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="user-content\" />
</ItemGroup>
</Project> </Project>