gzip-xif
Service icon

Gzip Compress/Decompress

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 12 June 2020
 by 
0.0
 (0 ratings)
gzip-xif

Gzip Compress/Decompress

Documentation
2.0.1

GZIP Compress/Decompress

Introduction

This component allows you to compress and decompress data in binary using the GZIP algorithm. GZIP is a method of data compression that reduces the size of files and saves disk space. GZIP can also speed up data transfer over the network, as compressed files are lighter and faster to send and receive.

How to use

To use this component, you need to add a reference to it in your module. Then, you can drag the CompressBinary or DecompressBinary actions to your logic flow and configure the input and output parameters.

CompressBinary

This action takes a binary as input and returns a compressed binary as 

output as output. The DecompressBinary action does the opposite: it takes a compressed binary as input and returns an uncompressed binary as output. These actions are compatible with any type of binary file, such as images, documents, audios, videos, etc.

Examples

Here are some examples of how to use the CompressBinary and DecompressBinary actions in your logic flow.

Compress an image

To compress an image, you need to have a binary variable that contains the image data. You can use the BinaryData extension to load an image from a file or a URL. Then, you can use the CompressBinary action to compress the image and store the result in another binary variable. You can also use the BinaryLength function to check the size of the original and compressed image.


Decompress an image

To decompress an image, you need to have a binary variable that contains the compressed image data. You can use the DecompressBinary action to decompress the image and store the result in another binary variable. You can also use the BinaryLength function to check the size of the compressed and decompressed image.


Troubleshooting

If you encounter any errors or problems when using this component, please check the following:

  • Make sure you have added a reference to the GZIP Compress/Decompress component in your module.
  • Make sure you have configured the input and output parameters correctly for each action.
  • Make sure you are using valid binary data for compression and decompression.
  • Make sure you are using compatible binary formats for compression and decompression. For example, do not try to compress a text file as an image or vice versa.

If you still need help, please contact the component support team.


1.0.0

Gzip encoded webservice use case.


If you want to configure a service that is encoded with the Gzip format and the OutSystems automation cannot automatically resolve the answer because it is encoded.
Use the component's test page and there you can get the answer that you should put in the answer of the service configuration in Outsystems.


add a new action to call the service and handle the decode

If this component meets your needs, don't forget to rate it.


Installation and Usage Manual for GZip Compress/Decompress Component

Introduction

This component allows you to compress and decompress data using the GZip algorithm. You can use this component to reduce the size of your data and save storage space or bandwidth. This component offers two actions: GZipCompress and GZipDecompress.

This component has an Outsystems extension in C# / .net and uses using System.IO.Compression to perform the compression and decompression operations. This directive was introduced in .NET Framework 4.5 to provide classes that support the compression and decompression of files and streams using various algorithms, such as GZip. Before that, it was necessary to use third-party libraries or native code to perform these operations. This directive made it easier to work with compressed files and data in C# and other .NET languages.

To use this component, you need to have OutSystems 11 or higher and the BinaryData extension installed in your environment.

Installation

To install this component in your OutSystems Service Studio, follow these steps:

  1. Go to the Forge page of the component: https://www.outsystems.com/forge/component-overview/8684/gzip-compress-decompress
  2. Click on the Download button to download the component to your computer.
  3. Open your OutSystems Service Studio and click on the Install from file button on the toolbar.
  4. Select the file that you downloaded from the Forge and click on Open.
  5. Wait for the installation to finish and click on Publish.
  6. The component is now installed and ready to use in your applications.

Usage

The component offers two actions to compress and decompress data using the GZip algorithm:

  • GZipCompress: This action receives a text or a binary as input and returns a compressed binary using the GZip algorithm. The action has two input parameters:

    • Input: The text or the binary that will be compressed. This parameter is mandatory.
    • IsText: A boolean value that indicates if the input is a text or a binary. If true, the input is treated as a text. If false, the input is treated as a binary. The default value is true.
  • The action has one output parameter:

    • Output: The compressed binary using the GZip algorithm.
  • This action uses using System.IO.Compression.GZipStream to create a compressed stream from the input data.

    For example, if you want to compress a text “Hello World” using this action, you can do something like this:


    The result will be a compressed binary with 23 bytes.

  • GZipDecompress: This action receives a compressed binary as input and returns a decompressed text or binary using the GZip algorithm. The action has two input parameters:

    • Input: The compressed binary that will be decompressed. This parameter is mandatory.
    • IsText: A boolean value that indicates if the output is a text or a binary. If true, the output is treated as a text. If false, the output is treated as a binary. The default value is true.
  • The action has one output parameter:

    • Output: The decompressed text or binary using the GZip algorithm.
  • This action uses using System.IO.Compression.GZipStream to create a decompressed stream from the input data.

    For example, if you want to decompress a compressed binary with 23 bytes using this action, you can do something like this:


    The result will be a decompressed text “Hello World” with 11 bytes.

Test Page

The component has a test page that you can access by this link: https://ruihmendes.outsystemscloud.com/Gzip/. This page allows you to test the two actions of the component: GZipCompress and GZipDecompress.

The test page has the following elements:

  • Input: A text field where you can enter the data that you want to compress or decompress. You can enter a text or a binary encoded in base64.
  • Output: A text field where you can see the compressed or decompressed data. The data will be shown as a binary encoded in base64.

    • Compress: A button that executes the GZipCompress action on the data entered in the Input field and shows the result in the Output field. The button also shows the size of the data in bytes before and after compression.
    • Decompress: A button that executes the GZipDecompress action on the data entered in the Input field and shows the result in the Output field. The button also shows the size of the data in bytes before and after decompression.
  • To test your component using the test page, follow these steps:

    1. Access the link https://ruihmendes.outsystemscloud.com/Gzip/ in your browser.
    2. In the Input field, enter the data that you want to compress or decompress. For example, enter the text “Hello World”.
    3. Click on the Compress button to compress the data using the GZip algorithm. Notice that the Output field shows the compressed data as a binary encoded in base64. Notice also that the Compress button shows the size of the data in bytes before and after compression. For example, the text “Hello World” has 11 bytes before compression and 23 bytes after compression.
    4. Copy the data from the Output field and paste it in the Input field.
    5. Click on the Decompress button to decompress the data using the GZip algorithm. Notice that the Output field shows the decompressed data as a text. Notice also that the Decompress button shows the size of the data in bytes before and after decompression. For example, the compressed data has 23 bytes before decompression and 11 bytes after decompression.
  • Support

    If you have any questions, issues or suggestions about this component, you can contact me by email at ruihmendes@gmail.com or by leaving a feedback on the Forge page of the component: https://www.outsystems.com/forge/component-overview/8684/gzip-compress-decompress

    References

    Here are some sources that I used to create this component or that might be useful for users who want to know more about the topic:

    • https://docs.microsoft.com/en-us/dotnet/api/system.io.compression?view=net-8.0
    • https://en.wikipedia.org/wiki/Gzip
    • https://www.base64encode.org/
    • https://www.howtogeek.com/182960/htg-explains-what-is-file-compression-and-how-does-it-work/