This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

etcher-image-stream

5.1.0 • Public • Published

etcher-image-stream

Get a readable stream from any type of OS image

npm version dependencies Build Status Build status

Installation

Install etcher-image-stream by running:

$ npm install --save etcher-image-stream

Documentation

imageStream.supportedFileTypes : Array.<String>

Kind: static property of imageStream
Summary: Supported file types
Access: public
Example

const imageStream = require('etcher-image-stream');
 
imageStream.supportedFileTypes.forEach(function(fileType) {
  console.log('Supported file type: ' + fileType.extension);
});

imageStream.getFromFilePath(file) ⇒ Promise

This function resolves an object containing the following properties:

  • Number size: The input file size.

  • ReadableStream stream: The input file stream.

  • TransformStream transform: A transform stream that performs any needed transformation to get the image out of the source input file (for example, decompression).

The purpose of separating the above components is to handle cases like showing a progress bar when you can't know the final uncompressed size.

In such case, you can pipe the stream through a progress stream using the input file size, and apply the transform after the progress stream.

Kind: static method of imageStream
Summary: Get an image stream from a file
Access: public
Fulfil: Object - image stream details

Param Type Description
file String file path

Example

const imageStream = require('etcher-image-stream');
 
imageStream.getFromFilePath('path/to/rpi.img.xz').then(function(image) {
  image.stream
    .pipe(image.transform)
    .pipe(fs.createWriteStream('/dev/disk2'));
});

imageStream.getImageMetadata(file) ⇒ Promise

This function is useful to determine the final size of an image after decompression or any other needed transformation, as well as other relevent metadata, if any.

NOTE: This function is known to output incorrect size results for bzip2. For this compression format, this function will simply return the size of the compressed file.

Kind: static method of imageStream
Summary: Get image metadata
Access: public
Fulfil: Object - image metadata

Param Type Description
file String file path

Example

const imageStream = require('etcher-image-stream');
 
imageStream.getImageMetadata('path/to/rpi.img.xz').then(function(metadata) {
  console.log(`The image display name is: ${metada.name}`);
  console.log(`The image url is: ${metada.url}`);
  console.log(`The image support url is: ${metada.supportUrl}`);
  console.log(`The image logo is: ${metada.logo}`);
});

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:

$ npm test

Contribute

Before submitting a PR, please make sure that you include tests, and that jshint runs without any warning:

$ npm run lint

License

etcher-image-stream is free software, and may be redistributed under the terms specified in the license.

Package Sidebar

Install

npm i etcher-image-stream

Weekly Downloads

2

Version

5.1.0

License

MIT

Last publish

Collaborators

  • balena.io