How to Create a Structured ZIP Archive in Node.JS

ZIP archives were developed to protect sensitive information and compress data into a format that can save space and be electronically shared with clients and partners. By utilizing the following API in Node.JS, you will be able to create a new ZIP archive by compressing files and folders into a structured format.

First, you can run this command to install the SDK:

npm install cloudmersive-convert-api-client --save

Or add this snippet to your package.json:

"dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}

Now, before you can call the function in Swift, you will need to fill in the information in the below input request:

{
"FilesInZip": [
{
"FileName": "string",
"FileContents": "string"
}
],
"DirectoriesInZip": [
{
"DirectoryName": "string",
"DirectoriesInDirectory": [
null
],
"FilesInDirectory": [
{
"FileName": "string",
"FileContents": "string"
}
]
}
]
}
At this point, we are ready to configure the API key and call the function:
var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveConvertApiClient.ZipArchiveApi();var request = new CloudmersiveConvertApiClient.CreateZipArchiveRequest(); // CreateZipArchiveRequest | Input requestvar callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.zipArchiveZipCreateAdvanced(request, callback);

And that’s it! If you need to obtain an API key, you can do so by registering for a free account on the ; this will provide 800 calls/month across any of our APIs.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.