Hello,
How can I modify my existing code to successfully convert a file into a gzip file and then encode it to a base64 string on BC14? Our customer is on this system for at least 2 more years, and despite multiple attempts, the current implementation does not work. It fails on the line StreamMgt.WriteGzipStreamToTempBlob() because the DotNet_GZipStream is not readable.
Here is the code I'm currently using:
procedure UploadAndCompress()
var
FileName: Text;
GZipAsText: Text;
InStream: InStream;
OutStream: OutStream;
DotNet_GZipStream: Codeunit DotNet_GZipStream;
DotNet_CompressionMode: Codeunit DotNet_CompressionMode;
StreamMgt: Codeunit /Stream Management/;
TempBlob: Record TempBlob;
TempBlob2: Record TempBlob;
begin
FileName := 'c://SomeFile.txt';
UploadIntoStream('Import', '', ' All Files (*.*)|*.*', FileName, InStream);
TempBlob.Blob.CreateOutStream(OutStream);
CopyStream(OutStream, InStream);
DotNet_CompressionMode.Compress();
StreamMgt.InitGzipStreamFromTempBlob(TempBlob, DotNet_CompressionMode, DotNet_GZipStream);
StreamMgt.WriteGzipStreamToTempBlob(DotNet_GZipStream, TempBlob2);
GZipAsText := TempBlob2.ToBase64String();
DotNet_GZipStream.CLOSE();
end;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,275 Most Valuable Professional
nmaenpaa 101,156