resin-zip-image v1.1.2
resin-zip-image
Resin.io Zip image manipulation utilities
(https://badges.gitter.im/Join Chat.svg)
Role
The intention of this module is to provide low level utilities to work with Resin.io Zip images.
THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.
Installation
Install resin-zip-image
by running:
$ npm install --save resin-zip-image
Documentation
- zip
- .getImageEntries(zip) ⇒ Array.<Object>
- .isValidZipImage(zip) ⇒ Boolean
- .extractImage(zip) ⇒ Promise
- .isZip(file) ⇒ Boolean
zip.getImageEntries(zip) ⇒ Array.<Object>
This function returns an array of objects that represent the "image" files found in the zip archive.
Kind: static method of zip
Summary: Get Zip image entries
Returns: Array.<Object> - image entries
Throws:
- Will throw if the zip is not a zip archive
Access: public
Param | Type | Description |
---|---|---|
zip | String | zip file path |
Example
zipImage = require('resin-zip-image')
imageEntries = zipImage.getImageEntries('path/to/archive.zip')
imageEntries.forEach (imageEntry) ->
console.log(imageEntry.name)
console.log(imageEntry.size)
zip.isValidZipImage(zip) ⇒ Boolean
A Zip is considered a Zip image if it contains only one
*.iso
or *.img
file.
It is still considered valid if it contains an image file and many other non-image files.
Kind: static method of zip
Summary: Check if a Zip is a Zip image
Returns: Boolean - whether the zip is a zip image
Access: public
Param | Type | Description |
---|---|---|
zip | String | zip file path |
Example
zipImage = require('resin-zip-image')
if zipImage.isValidZipImage('path/to/archive.zip')
console.log('This is a Zip image!')
zip.extractImage(zip) ⇒ Promise
Kind: static method of zip
Summary: Extract the image file from a Zip image
Throws:
- Will throw if the zip is not a zip image
Access: public
Fulfil: ReadableStream - image file
Param | Type | Description |
---|---|---|
zip | String | zip file path |
Example
zipImage = require('resin-zip-image')
zipImage.extractImage('path/to/archive.zip').then (stream) ->
stream.pipe(fs.createWriteStream('output.img'))
zip.isZip(file) ⇒ Boolean
Kind: static method of zip
Summary: Check if a file is a zip archive
Returns: Boolean - whether the file is a zip archive
Access: public
Param | Type | Description |
---|---|---|
file | String | file path |
Example
zipImage = require('resin-zip-image')
if zipImage.isZip('path/to/file')
console.log('This file is a Zip archive!')
Support
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Tests
Run the test suite by doing:
$ gulp test
Contribute
- Issue Tracker: github.com/resin-io/resin-zip-image/issues
- Source Code: github.com/resin-io/resin-zip-image
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
License
The project is licensed under the Apache 2.0 license.