| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
Archive.CompressText
Compresses a text into a new archive.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| Archive | 14.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Archive.CompressText"; Format; Filter; Destination; FileName; Text; Encoding { ; Options; Password } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| Format | The format to use. Formats: ar, arbsd, argnu, arsvr4, bsdtar, cd9660, cpio, gnutar, iso, iso9660, mtree, mtree-classic, newc, odc, oldtar, pax, paxr, posix, raw, rpax, shar, shardump, ustar, v7tar, v7, warc, xar, zip. |
"zip" | |
| Filter | The filter to use. For zip format can be store, bzip2, zstd or deflate. Filters: b64encode, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, uuencode, xz, zstd. Not all filters can be combined with all formats. |
"deflate" | |
| Destination | The native file path to the destination archive. Or file name for container. |
"C:\test.zip" | |
| FileName | The file name or path to use for the entry in the archive. | "export.xml" | |
| Text | The text to compress. We use UTF-8 encoding. |
"Hello World" | |
| Encoding | The text encoding for text parameter. Default is UTF-8. |
"UTF8" | |
| Options | The options to pass to writer. This is a comma-separated list of options. Option names can be prefixed with module name. Sample options: compression-level=9 zip:encryption=zipcrypt zip:encryption=aes128 zip:encryption=aes256 zip64 gzip:compression-level=9 hdrcharset=UTF-8 |
"zip:encryption=zipcrypt" | Optional |
| Password | The passphrase to use for password protection. | "secret" | Optional |
Result
Returns container or error.
Description
Compresses a text into a new archive.Supports various compression algorithms and encryption.
Examples
Compress some text to zip file:
Set Variable [ $Container; Value: MBS( "Archive.CompressText"; "zip"; "deflate"; "test.zip"; $text; "compression-level=9") ]
Compress XML and add to email:
# get some XML
Set Variable [ $XML ; Value: "<test>Hello</test>" ]
# Compress it
Set Variable [ $CompressedXML ; Value: MBS( "Archive.CompressText"; "zip"; "deflate"; "export.zip"; "export.xml"; $xml; "UTF-8"; "compression-level=9") ]
# now add to email
Set Variable [ $email ; Value: MBS( "SendMail.CreateEmail") ]
Set Variable [ $r ; Value: MBS( "SendMail.AddAttachmentContainer"; $Email; $CompressedXML; "export.zip"; "application/zip" ) ]
Set Variable [ $r ; Value: MBS( "SendMail.SetPlainText"; $email; "Dear " & Contacts::FullName & ¶ & ¶ & "Attached you find the export from " & Get(CurrentDate ) & ¶ & ¶ & "Greetings" & ¶ & "Your FileMaker Server") ]
Set Variable [ $XML ; Value: "<test>Hello</test>" ]
# Compress it
Set Variable [ $CompressedXML ; Value: MBS( "Archive.CompressText"; "zip"; "deflate"; "export.zip"; "export.xml"; $xml; "UTF-8"; "compression-level=9") ]
# now add to email
Set Variable [ $email ; Value: MBS( "SendMail.CreateEmail") ]
Set Variable [ $r ; Value: MBS( "SendMail.AddAttachmentContainer"; $Email; $CompressedXML; "export.zip"; "application/zip" ) ]
Set Variable [ $r ; Value: MBS( "SendMail.SetPlainText"; $email; "Dear " & Contacts::FullName & ¶ & ¶ & "Attached you find the export from " & Get(CurrentDate ) & ¶ & ¶ & "Greetings" & ¶ & "Your FileMaker Server") ]
Compress text and use Windows ANSI encoding for both the text in the text file and the file name encoding:
MBS( "Archive.CompressText"; "zip"; "deflate"; "/Users/cs/Desktop/test.zip"; "hällo.txt"; "Hällo Text"; "Windows"; "hdrcharset=cp1252")
Compress with password:
MBS( "Archive.CompressText"; "zip"; "deflate"; "/Users/cs/Desktop/test.zip"; "hällo.txt"; "Hällo Text"; "UTF-8"; "hdrcharset=UTF-8¶zip:encryption=zipcrypt"; "Hello")
Compress some text and extract it again:
Let ( [
archive = MBS( "Archive.CompressText"; "zip"; "deflate"; "test.zip"; "test.txt"; "Hello World. Just a test to check compresssion."; "UTF-8"; "hdrcharset=UTF-8");
container = MBS( "Archive.ExtractFile"; archive; "test.txt" );
text = MBS( "Text.ReadTextFromContainer"; Container; "UTF-8" )
]; text )
Example result: Hello World. Just a test to check compresssion.
archive = MBS( "Archive.CompressText"; "zip"; "deflate"; "test.zip"; "test.txt"; "Hello World. Just a test to check compresssion."; "UTF-8"; "hdrcharset=UTF-8");
container = MBS( "Archive.ExtractFile"; archive; "test.txt" );
text = MBS( "Text.ReadTextFromContainer"; Container; "UTF-8" )
]; text )
Example result: Hello World. Just a test to check compresssion.
Same with zstd in an ar file:
Let ( [
archive = MBS( "Archive.CompressText"; "ar"; "zstd"; "test.ar"; "test.txt"; "Hello World. Just a test to check compresssion."; "UTF-8"; "");
container = MBS( "Archive.ExtractFile"; archive; "test.txt" );
text = MBS( "Text.ReadTextFromContainer"; Container; "UTF-8" )
]; text )
archive = MBS( "Archive.CompressText"; "ar"; "zstd"; "test.ar"; "test.txt"; "Hello World. Just a test to check compresssion."; "UTF-8"; "");
container = MBS( "Archive.ExtractFile"; archive; "test.txt" );
text = MBS( "Text.ReadTextFromContainer"; Container; "UTF-8" )
]; text )
See also
- Archive.Compress
- Archive.Extract
- Archive.ExtractFile
- SendMail.AddAttachmentContainer
- SendMail.CreateEmail
- SendMail.SetPlainText
- Text.ReadTextFromContainer
Release notes
- Version 15.3
- Added bzip2 and zstd as filter for zip archives for Archive.Compress, Archive.CompressContainer, Archive.CompressText and Archive.Create functions.
- Version 14.3
- Added Archive.CompressText function.
Blog Entries
- MBS FileMaker Plugin, version 15.3pr5
- MBS FileMaker Plugin 14.3 News
- Neues MBS Plugin 14.3 für Claris FileMaker
- MBS FileMaker Plugin 14.3 for Claris FileMaker
- Compress and Send
- MBS FileMaker Plugin, version 14.3pr7
- Store large texts as container fields
- MBS FileMaker Plugin, version 14.3pr2
This function checks for a license.
Created 9th June 2024, last changed 10th February 2026