diff --git a/Presentation/HushianWebApp/Pages/Chat.razor b/Presentation/HushianWebApp/Pages/Chat.razor
index fc30509..df315d6 100644
--- a/Presentation/HushianWebApp/Pages/Chat.razor
+++ b/Presentation/HushianWebApp/Pages/Chat.razor
@@ -219,7 +219,23 @@
}
-
@msg.text
+
+
+ @if (msg.FileContent != null && msg.FileContent.Length > 0 && !string.IsNullOrWhiteSpace(msg.FileType) && msg.FileType.StartsWith("image/"))
+ {
+
+
+
+ @if (!string.IsNullOrWhiteSpace(msg.text))
+ {
+
@msg.text
+ }
+ }
+ else
+ {
+ @msg.text
+ }
+
@if (msg.Type != Common.Enums.ConversationType.UE)
{
if (msg.IsRead)
@@ -487,6 +503,21 @@
+ }
+ private static string GetImageDataUrl(string? fileType, byte[]? content)
+ => (string.IsNullOrWhiteSpace(fileType) || content == null || content.Length == 0)
+ ? string.Empty
+ : $"data:{fileType};base64,{Convert.ToBase64String(content)}";
+
+ private static string GetDownloadFileName(string? fileName, string? fileType)
+ {
+ if (!string.IsNullOrWhiteSpace(fileName)) return fileName;
+ var ext = "";
+ if (!string.IsNullOrWhiteSpace(fileType) && fileType.StartsWith("image/"))
+ {
+ ext = "." + fileType.Split('/').Last();
+ }
+ return $"image_{DateTimeOffset.Now.ToUnixTimeSeconds()}{ext}";
}
}
diff --git a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
index f45ebba..18da21e 100644
--- a/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
+++ b/Presentation/HushianWebApp/Pages/FromUserSide/UserCP.razor
@@ -79,7 +79,9 @@
@if (msg.FileContent != null && msg.FileContent.Length > 0 && !string.IsNullOrWhiteSpace(msg.FileType) && msg.FileType.StartsWith("image/"))
{
-

+
+
+
@if (!string.IsNullOrWhiteSpace(msg.text))
{
@msg.text
@@ -507,6 +509,22 @@
SelectedImagePreview = null;
return Task.CompletedTask;
}
+
+ private static string GetImageDataUrl(string? fileType, byte[]? content)
+ => (string.IsNullOrWhiteSpace(fileType) || content == null || content.Length == 0)
+ ? string.Empty
+ : $"data:{fileType};base64,{Convert.ToBase64String(content)}";
+
+ private static string GetDownloadFileName(string? fileName, string? fileType)
+ {
+ if (!string.IsNullOrWhiteSpace(fileName)) return fileName;
+ var ext = "";
+ if (!string.IsNullOrWhiteSpace(fileType) && fileType.StartsWith("image/"))
+ {
+ ext = "." + fileType.Split('/').Last();
+ }
+ return $"image_{DateTimeOffset.Now.ToUnixTimeSeconds()}{ext}";
+ }
}