1.1.2 • Published 8 years ago

resin-zip-image v1.1.2

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
8 years ago

resin-zip-image

Resin.io Zip image manipulation utilities

npm version dependencies Build Status Build status Gitter(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>

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

ParamTypeDescription
zipStringzip 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

ParamTypeDescription
zipStringzip 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

ParamTypeDescription
zipStringzip 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

ParamTypeDescription
fileStringfile 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

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.

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago