Fix gestione allegati e creato metodo di esportazione log
This commit is contained in:
23
SteUp.Maui/Core/Utility/UtilityFile.cs
Normal file
23
SteUp.Maui/Core/Utility/UtilityFile.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using SteUp.Shared.Core.Dto;
|
||||
|
||||
namespace SteUp.Maui.Core.Utility;
|
||||
|
||||
public static class UtilityFile
|
||||
{
|
||||
public static async Task<AttachedDto> ConvertToDto(FileResult file, AttachedDto.TypeAttached type)
|
||||
{
|
||||
var stream = await file.OpenReadAsync();
|
||||
using var ms = new MemoryStream();
|
||||
await stream.CopyToAsync(ms);
|
||||
|
||||
return new AttachedDto
|
||||
{
|
||||
Name = file.FileName,
|
||||
Path = file.FullPath,
|
||||
MimeType = file.ContentType,
|
||||
DimensionBytes = ms.Length,
|
||||
FileBytes = ms.ToArray(),
|
||||
Type = type
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user