mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 20:21:37 +00:00
Added workaround using base64 embedding
This commit is contained in:
parent
6cf14a57c7
commit
3220c8970f
@ -31,7 +31,7 @@
|
||||
@if (this.Document?.IsImage ?? false)
|
||||
{
|
||||
<MudTabPanel Text="@T("Image View")" Icon="@Icons.Material.Filled.Image">
|
||||
<MudImage ObjectFit="ObjectFit.ScaleDown" Src="@this.Document.FilePathAsUrl"/>
|
||||
<MudImage ObjectFit="ObjectFit.ScaleDown" Src="@this.imageDataUrl"/>
|
||||
</MudTabPanel>
|
||||
}
|
||||
else
|
||||
|
||||
@ -30,13 +30,29 @@ public partial class DocumentCheckDialog : MSGComponentBase
|
||||
[Inject]
|
||||
private ILogger<DocumentCheckDialog> Logger { get; init; } = null!;
|
||||
|
||||
private string imageDataUrl = string.Empty;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender && this.Document is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!this.Document.IsImage)
|
||||
if (this.Document.IsImage)
|
||||
{
|
||||
// Load image as Base64 data URL since browsers cannot access local file:// URLs:
|
||||
if (this.Document is FileAttachmentImage imageAttachment)
|
||||
{
|
||||
var (success, base64Content) = await imageAttachment.TryAsBase64();
|
||||
if (success)
|
||||
{
|
||||
var mimeType = imageAttachment.DetermineMimeType();
|
||||
this.imageDataUrl = ImageHelpers.ToDataUrl(base64Content, mimeType);
|
||||
this.StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileContent = await UserFile.LoadFileData(this.Document.FilePath, this.RustService, this.DialogService);
|
||||
this.FileContent = fileContent;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user