From e20eb9e32a25043e17d303402d99604ef0c7960e Mon Sep 17 00:00:00 2001 From: tomas-sexenian Date: Thu, 14 Sep 2023 11:12:30 -0300 Subject: [PATCH 1/3] Send manipulated images to temp media directory Issue: 104803 --- dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs index 06fb16db1..da25b3524 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs @@ -5783,7 +5783,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); @@ -5815,7 +5815,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); @@ -6054,6 +6054,7 @@ public static string FlipVertically(string imageFile) public static string Save(Image bitmap, string imageFile, ImageFormat format) { + System.Diagnostics.Debugger.Launch(); string destinationImagePath = string.Empty; using (MemoryStream ms = new MemoryStream()) { @@ -6076,7 +6077,7 @@ public static string Save(Image bitmap, string imageFile, ImageFormat format) 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()); + string destinationImageName = FileUtil.getTempFileName(Preferences.getTMP_MEDIA_PATH(), Path.GetFileNameWithoutExtension(sourceImage.GetName()), sourceImage.GetExtension()); GxFile destinationImage = new GxFile(GxContext.StaticPhysicalPath(), destinationImageName); destinationImage.Create(ms); destinationImage.Close(); From cf6581d01c107a9402764cd275d2621da28adfc1 Mon Sep 17 00:00:00 2001 From: tomas-sexenian Date: Thu, 14 Sep 2023 19:15:52 -0300 Subject: [PATCH 2/3] Remove debugger call and use temp media path as gxfile destination --- dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs index da25b3524..5453d4aea 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs @@ -6054,7 +6054,6 @@ public static string FlipVertically(string imageFile) public static string Save(Image bitmap, string imageFile, ImageFormat format) { - System.Diagnostics.Debugger.Launch(); string destinationImagePath = string.Empty; using (MemoryStream ms = new MemoryStream()) { @@ -6077,8 +6076,9 @@ public static string Save(Image bitmap, string imageFile, ImageFormat format) imageFile = Path.GetFileName(uri.AbsolutePath); } GxFile sourceImage = new GxFile(GxContext.StaticPhysicalPath(), imageFile); - string destinationImageName = FileUtil.getTempFileName(Preferences.getTMP_MEDIA_PATH(), Path.GetFileNameWithoutExtension(sourceImage.GetName()), sourceImage.GetExtension()); - GxFile destinationImage = new GxFile(GxContext.StaticPhysicalPath(), destinationImageName); + string tempDirectory = Preferences.getTMP_MEDIA_PATH(); + string destinationImageName = FileUtil.getTempFileName(tempDirectory, Path.GetFileNameWithoutExtension(sourceImage.GetName()), sourceImage.GetExtension()); + GxFile destinationImage = new GxFile(tempDirectory, destinationImageName); destinationImage.Create(ms); destinationImage.Close(); destinationImagePath = destinationImage.GetAbsoluteName(); From 965cda39df7db9b92f40952ba1fdaa12450d5a3b Mon Sep 17 00:00:00 2001 From: tomas-sexenian Date: Fri, 20 Oct 2023 16:03:41 -0300 Subject: [PATCH 3/3] Manipulated image wasn't being created in external storage --- .../dotnetframework/GxClasses/Core/GXUtilsCommon.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs index 5453d4aea..b63942014 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs @@ -6075,13 +6075,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 tempDirectory = Preferences.getTMP_MEDIA_PATH(); - string destinationImageName = FileUtil.getTempFileName(tempDirectory, Path.GetFileNameWithoutExtension(sourceImage.GetName()), sourceImage.GetExtension()); - GxFile destinationImage = new GxFile(tempDirectory, 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) {