using SteUp.Maui.Core.Services; using SteUp.Shared.Core.Dto; namespace SteUp.Maui.Core.Utility; public static class UtilityFile { public static async Task ConvertToDto(FileResult file, AttachedDto.TypeAttached type) { var stream = await file.OpenReadAsync(); using var ms = new MemoryStream(); await stream.CopyToAsync(ms); var bytes = ms.ToArray(); // Unico punto di passaggio di fotocamera e galleria: raddrizziamo qui, cosi' // miniature, salvataggio locale e upload lavorano tutti su pixel gia' dritti. if (type == AttachedDto.TypeAttached.Image) bytes = ImageOrientation.Normalize(bytes); return new AttachedDto { Name = file.FileName, Path = file.FullPath, MimeType = file.ContentType, DimensionBytes = bytes.Length, FileBytes = bytes, Type = type }; } }