From e24f91b5f1b3b8756070281bf054f03b6f9e2361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Mon, 13 Nov 2023 13:29:13 -0300 Subject: [PATCH] Send manipulated images to temp media directory (#874) * Send manipulated images to temp media directory Issue: 104803 * Remove debugger call and use temp media path as gxfile destination * Manipulated image wasn't being created in external storage --- .../GxClasses/Core/GXUtilsCommon.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs index d4bb6a16d..9f2919a80 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs @@ -5782,7 +5782,7 @@ private static Bitmap BitmapCreateFromStream(string filePathOrUrl) { try { - byte[] data = httpClient.GetByteArrayAsync(filePathOrUrl).Result; + byte[] data = httpClient.GetByteArrayAsync(uri).Result; using (MemoryStream mem = new MemoryStream(data)) { return new Bitmap(mem); @@ -5814,7 +5814,7 @@ private static Image ImageCreateFromStream(string filePathOrUrl) { try { - byte[] data = httpClient.GetByteArrayAsync(filePathOrUrl).Result; + byte[] data = httpClient.GetByteArrayAsync(uri).Result; using (MemoryStream mem = new MemoryStream(data)) { return Image.FromStream(mem); @@ -6077,12 +6077,15 @@ public static string Save(Image bitmap, string imageFile, ImageFormat format) Uri uri = new Uri(imageFile); imageFile = Path.GetFileName(uri.AbsolutePath); } - GxFile sourceImage = new GxFile(GxContext.StaticPhysicalPath(), imageFile); - string destinationImageName = FileUtil.getTempFileName(sourceImage.GetDirectory().GetAbsoluteName(), Path.GetFileNameWithoutExtension(sourceImage.GetName()), sourceImage.GetExtension()); - GxFile destinationImage = new GxFile(GxContext.StaticPhysicalPath(), destinationImageName); + string destinationImageName = FileUtil.getTempFileName( + "", + Path.GetFileNameWithoutExtension(imageFile), + Path.GetExtension(imageFile).TrimStart('.') + ); + GxFile destinationImage = new GxFile(Preferences.getTMP_MEDIA_PATH(), destinationImageName, GxFileType.PrivateAttribute); destinationImage.Create(ms); destinationImage.Close(); - destinationImagePath = destinationImage.GetAbsoluteName(); + destinationImagePath = destinationImage.GetURI(); } catch (Exception ex) {