#include "demo_guard.h" RENDER(Request& context) { if(!test_demo_request_allowed(context)) { test_demo_render_restricted_html(context, "ZIP Demo", "create and extract temporary server-side archive files"); return; } String base = "/tmp/uce-demo-zip"; String archive = path_join(base, "demo.zip"); String extract_dir = path_join(base, "extract"); mkdir(base); mkdir(extract_dir); DValue entries; entries["hello.txt"] = "Hello from a generated ZIP archive.\n"; entries["notes/readme.txt"] = "zip_create(), zip_list(), zip_read(), and zip_extract() are available to UCE pages.\n"; zip_create(archive, entries); DValue listing = zip_list(archive); String hello = zip_read(archive, "hello.txt"); zip_extract(archive, extract_dir); String extracted = file_get_contents(path_join(extract_dir, "notes/readme.txt")); String gz_source = "This string was compressed with gz_compress() and restored with gz_uncompress()."; String gz_body = gz_compress(gz_source); String gz_roundtrip = gz_uncompress(gz_body); ?>

UCE Test Suite / ZIP

This demo creates a temporary archive at , lists it, reads one member, and extracts it under .

zip_list()

zip_read()

Extracted File

gzip Helpers

Source bytes: ; compressed bytes: