neoZip
Plugin for creating, reading and editing .zip files.
Based on:
https://github.com/Stuk/jszip
https://stuk.github.io/jszip/
Sample App:
https://visualneo.com/tutorials/neozip
Description
The neoZip plugin for VisualNEO Web allows applications to create, read, edit, and manage .zip files, enabling users to bundle files, extract data, or dynamically generate zip archives. This plugin is built on the JSZip library and is useful for applications needing file compression or storage features, such as data export, backup, or content sharing. Here’s a detailed overview of its commands and usage:
Creating a New Zip File
The neoZipCreate command initializes a new zip file, which can then be populated with files and folders.
- Command: neoZipCreate
- Syntax: neoZipCreate "zipName"
- zipName: A unique name for the zip instance.
Example:
neoZipCreate "myZipFile"
This command creates a new zip file named myZipFile, allowing further additions.
Adding Files and Folders
The plugin includes commands to add files in various formats to the zip archive:
- neoZipAddTextFile: Adds a plain text file.
- Syntax: neoZipAddTextFile "zipName" "fileName" "File content"
- neoZipAddBinaryFile: Adds a binary file.
- Syntax: neoZipAddBinaryFile "zipName" "fileName" "[fileContent]"
- neoZipAddBase64File: Adds a base64-encoded file.
- Syntax: neoZipAddBase64File "zipName" "fileName" "[fileContent]"
- neoZipAddFolder: Adds a new folder to the zip file.
- Syntax: neoZipAddFolder "zipName" "folderName"
Example for Adding Text File:
neoZipAddTextFile "myZipFile" "docs/readme.txt" "This is the readme file."
This adds a text file named readme.txt to the docs folder inside myZipFile.
Saving the Zip File
The neoZipSave command saves the zip archive as a downloadable .zip file, with optional compression.
- Command: neoZipSave
- Syntax: neoZipSave "zipName" compression "fileName"
- compression: Compression level (e.g., "DEFLATE").
- fileName: Desired name for the saved .zip file.
Example:
neoZipSave "myZipFile" "4" "archive.zip"
This saves myZipFile as archive.zip with 4 level compression.
Loading and Reading Zip Files
To load an existing .zip file, use the neoZipLoad or neoZipLoadLocal command, enabling the app to read or manipulate its contents.
- neoZipLoad: Loads a zip file from a specified URL.
- Syntax: neoZipLoad "zipName" "filePath" callbackSub
- neoZipLoadLocal: Loads a user-selected zip file.
- Syntax: neoZipLoadLocal "inputFileName" "zipName" callbackSub
Once loaded, use commands like neoZipReadTextFile or neoZipReadBinaryFile to extract file content.
Example for Loading:
neoZipLoad "myZipFile" "https://example.com/files/data.zip" "onLoadComplete"
This loads data.zip from a URL into myZipFile, triggering onLoadComplete after loading.
Managing and Modifying Zip Contents
The plugin provides commands to modify zip content by removing files or retrieving a file list.
- neoZipRemove: Removes a file or folder from the zip archive.
- Syntax: neoZipRemove "zipName" "fileName"
- neoZipGetFileList: Retrieves a list of all files within the zip archive.
- Syntax: neoZipGetFileList "zipName" resultVar
Example:
neoZipRemove "myZipFile" "docs/oldfile.txt"
This removes oldfile.txt from the docs folder in myZipFile.
Practical Applications
The neoZip plugin is useful for:
- Data Export and Backup: Exporting user data or backups as zip files.
- Content Sharing: Bundling multiple files for download or sharing.
- File Management: Managing file storage within applications.
The neoZip plugin adds versatile file compression and archival capabilities to VisualNEO Web, enhancing applications with efficient file handling and data management.
neoZipCreate
|
Category: |
neoZip |
|
Syntax: |
neoZipCreate "neoZipName"
neoZipName neoZip name (ie: myzip) |
neoZipAddFolder
|
Purpose: |
Create a new folder |
|
Category: |
neoZip |
|
Syntax: |
neoZipAddFolder "neoZipName" "folderName"
neoZipName neoZip name folderName Folder name |
neoZipSave
|
Purpose: |
Save (download) a .zip file |
|
Category: |
neoZip |
|
Syntax: |
neoZipSave "neoZipName" compression "fileName"
neoZipName neoZip name compression Compression fileName File name (ie: myfile.zip) |
neoZipSaveAsBase64
|
Purpose: |
Save a .zip file into a variable using Base64 encoding |
|
Category: |
neoZip |
|
Syntax: |
neoZipSaveAsBase64 "neoZipName" compression resultVar callbackSub
neoZipName neoZip name compression Compression resultVar Variable to store result callbackSub Callback subroutine (optional) |
neoZipSaveAsBinary
|
Purpose: |
Save a .zip file into a variable in binary format |
|
Category: |
neoZip |
|
Syntax: |
neoZipSaveAsBinary "neoZipName" compression resultVar callbackSub
neoZipName neoZip name compression Compression resultVar Variable to store result callbackSub Callback subroutine (optional) |
neoZipAddTextFile
|
Purpose: |
Add (or update) a text file to the zip file. |
|
Category: |
neoZip |
|
Syntax: |
neoZipAddTextFile "neoZipName" "fileName" "fileContent"
neoZipName neoZip name fileName File name (ie: myfile.txt or myfolder/myfile.txt) fileContent Text content |
neoZipAddBase64File
|
Purpose: |
Add (or update) a base64 enconded file to the zip file. |
|
Category: |
neoZip |
|
Syntax: |
neoZipAddBase64File "neoZipName" "fileName" "fileContent"
neoZipName neoZip name fileName File name (ie: myfile.jpg or myfolder/myfile.jpg) fileContent Content |
neoZipAddBinaryFile
|
Purpose: |
Add (or update) a binary file to the zip file. |
|
Category: |
neoZip |
|
Syntax: |
neoZipAddBinaryFile "neoZipName" "fileName" "fileContent"
neoZipName neoZip name fileName File name (ie: myfile.mp3 or myfolder/myfile.mp3) fileContent Content |
neoZipReadTextFile
|
Purpose: |
Read a text file content |
|
Category: |
neoZip |
|
Syntax: |
neoZipReadTextFile "neoZipName" "fileName" contentVar callbackSub
neoZipName neoZip name fileName File name (ie: myfile.txt or myfolder/myfile.txt) contentVar Variable to store the text content callbackSub Callback subroutine (optional) |
neoZipReadBase64File
|
Purpose: |
Read a file content base64 encoded |
|
Category: |
neoZip |
|
Syntax: |
neoZipReadBase64File "neoZipName" "fileName" contentVar callbackSub
neoZipName neoZip name fileName File name (ie: myfile.txt or myfolder/myfile.txt) contentVar Variable to store the text content callbackSub Callback subroutine (optional) |
neoZipReadBinaryFile
|
Purpose: |
Read a file as binary content |
|
Category: |
neoZip |
|
Syntax: |
neoZipReadBinaryFile "neoZipName" "fileName" contentVar callbackSub
neoZipName neoZip name fileName File name (ie: myfile.txt or myfolder/myfile.txt) contentVar Variable to store the text content callbackSub Callback subroutine (optional) |
neoZipRemove
|
Purpose: |
Remove a file or folder (included its content) |
|
Category: |
neoZip |
|
Syntax: |
neoZipRemove "neoZipName" "fileName"
neoZipName neoZip name fileName File or folder name (ie: myfile.txt or myfolder or myfolder/myfile.txt) |
neoZipLoad
|
Purpose: |
Load an existing .zip file from a URL |
|
Category: |
neoZip |
|
Syntax: |
neoZipLoad "neoZipName" "filePath" callbackSub
neoZipName neoZip name filePath File URL (ie: myfolder/myfile.zip) callbackSub Callback subroutine (optional) |
neoZipLoadLocal
|
Purpose: |
Load an existing .zip file selected by user. |
|
Category: |
neoZip |
|
Syntax: |
neoZipLoadLocal "inputFileName" "neoZipName" callbackSub
inputFileName Select a File Input object neoZipName neoZip name callbackSub Callback subroutine (optional) |
neoZipGetFileList
|
Purpose: |
Get .zip files list into an Array |
|
Category: |
neoZip |
|
Syntax: |
neoZipGetFileList "neoZipName" resultVar
neoZipName neoZip name resultVar Variable name to store result |
Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation