Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Archive.GZipDecompress

Extracts content of gzip file as container.

Component Version macOS Windows Linux Server iOS SDK
Archive 11.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Archive.GZipDecompress"; Archive { ; New file name; Options } )   More

Parameters

Parameter Description Example Flags
Archive Either container with archive or native file path. "C:\test\test.zip"
New file name The new file name to use for container.
Default is "data".
Optional
Options The options to pass to reader.
This is a comma-separated list of options. Option names can be prefixed with module name.
Optional

Result

Returns container value or error.

Description

Extracts content of gzip file as container.
You may use Archive.FileList to get a list of file names in the archive.

Since a pure gz file doesn't have an archive inside like a tar.gz, this function will return the uncompressed content as new file.
Please pass file name to have FileMaker handle the file type correctly, e.g. show picture.

Examples

Extract gzip file:

Set Variable [ $r ; Value: MBS( "Archive.GZipDecompress"; "/Users/cs/Desktop/test.jpg.gz"; "test.jpg") ]
Set Field [ Contacts::Photo Container ; $r ]

Extract text from gzip compressed text with prefixed length:

# get some response string, gzip compressed with length before
// Set Variable [ $response ; Value: GzipDecompress::InputString ]
Set Variable [ $response ; Value: "RAAAAB+LCAAAAAAABACrZlBicGbIZ0hhSAWyrBhMGAwYDBl0gOwwhkSGHIZSqLgSEIJEg4BqSxlKkE RrGQAjtv6kRAAAAA==" ]
# convert base64 to Hex
Set Variable [ $hex ; Value: MBS( "Text.DecodeHexFromBase64"; $response ) ]
# now we can remove the first 4 bytes with length
Set Variable [ $hexNum ; Value: Left($hex; 8) ]
Set Variable [ $Rest ; Value: Middle ( $hex; 9; 100000000 ) ]
# we can decode the length value
Set Variable [ $len ; Value: MBS("Math.DecodeNumber"; "Integer"; 32; $hexNum) ]
# and read to container value from hex
Set Variable [ $Cont ; Value: MBS( "Container.DecodeFromHex"; "FILE"; $Rest; "test.gz" ) ]
# now decompress gzip
Set Variable [ $Decompressed ; Value: MBS( "Archive.GZipDecompress"; $cont; "test.txt") ]
# and read it as text. it is little endian UTF-16 here!
Set Variable [ $result ; Value: MBS( "Text.ReadTextFromContainer"; $Decompressed; "UTF-16LE") ]
# show in field
Set Field [ GzipDecompress::OutputString ; $result ]
Show Custom Dialog [ "Result" ; $result ]

Example result:
{"Code":401,"Value":"","Route":""}

See also

Release notes

Blog Entries

This function checks for a license.

Created 18th June 2021, last changed 4th July 2024


Archive.FileList - Archive.LZ4Version