From 55cd62ec9c026668c3417499cbc73a57d252b22f Mon Sep 17 00:00:00 2001 From: Alek-ban Date: Fri, 27 Feb 2026 12:32:55 +0300 Subject: [PATCH] feat: ImageStorageService add sub dirs --- GSS2.Core/Hardware/ImageStorageService.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/GSS2.Core/Hardware/ImageStorageService.cs b/GSS2.Core/Hardware/ImageStorageService.cs index 018ff3e..5dfe547 100644 --- a/GSS2.Core/Hardware/ImageStorageService.cs +++ b/GSS2.Core/Hardware/ImageStorageService.cs @@ -22,10 +22,10 @@ public class ImageStorageService _logger.LogInformation("Initialized"); } - public async Task SaveAsync(Stream fileStream, string extension, CancellationToken ct = default) + public async Task SaveAsync(Stream fileStream, string extension, string subDirectory, CancellationToken ct = default) { var fileName = GenerateFileName(extension); - var fullPath = GetFullPath(fileName); + var fullPath = GetFullPath(fileName, subDirectory); var directory = Path.GetDirectoryName(fullPath)!; Directory.CreateDirectory(directory); @@ -45,15 +45,15 @@ public class ImageStorageService return fileName; } - public Stream OpenRead(string fileName) + public Stream OpenRead(string fileName, string subDirectory) { - var fullPath = GetFullPath(fileName); + var fullPath = GetFullPath(fileName, subDirectory); return new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read); } - public bool Delete(string fileName) + public bool Delete(string fileName, string subDirectory) { - var fullPath = GetFullPath(fileName); + var fullPath = GetFullPath(fileName, subDirectory); if (!File.Exists(fullPath)) return false; @@ -68,11 +68,11 @@ public class ImageStorageService return $"{guid}{extension}"; } - public string GetFullPath(string fileName) + public string GetFullPath(string fileName, string subDirectory) { var level1 = fileName.Substring(0, 2); var level2 = fileName.Substring(2, 2); - return Path.Combine(_rootDirectory.FullName, level1, level2, fileName); + return Path.Combine(_rootDirectory.FullName, subDirectory, level1, level2, fileName); } } \ No newline at end of file