Resin.io Zip image manipulation utilities
![Gitter](https://badges.gitter.im/Join Chat.svg)
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.
Install resin-zip-image
by running:
$ npm install --save resin-zip-image
- zip
- .getImageEntries(zip) ⇒
Array.<Object>
- .isValidZipImage(zip) ⇒
Boolean
- .extractImage(zip) ⇒
Promise
- .isZip(file) ⇒
Boolean
- .getImageEntries(zip) ⇒
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)
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!')
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'))
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!')
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
Run the test suite by doing:
$ gulp test
- 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
The project is licensed under the Apache 2.0 license.