namespace Fitness_core_BE.Helpers { // BusinessLogoId (ClientBusiness) holds a relative /Uploads path, not a public URL — there's // no static-file serving configured for it, so the only way to hand it to a client (web or // mobile) is to read the bytes server-side and inline them as a base64 data URL. public static class BusinessLogoHelper { public static async Task ReadAsDataUrlAsync(string? businessLogoId) { if (string.IsNullOrEmpty(businessLogoId)) return null; string uploadsRoot = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..")); string relativePath = Uri.UnescapeDataString(businessLogoId).Replace("/", Path.DirectorySeparatorChar.ToString()); string filePath = uploadsRoot + relativePath; if (!File.Exists(filePath)) return null; byte[] bytes = await File.ReadAllBytesAsync(filePath); string ext = Path.GetExtension(filePath).TrimStart('.').ToLowerInvariant(); string mime = ext == "png" ? "image/png" : ext == "webp" ? "image/webp" : "image/jpeg"; return $"data:{mime};base64,{Convert.ToBase64String(bytes)}"; } } }