Get a readable stream from any type of OS image
Install etcher-image-stream
by running:
$ npm install --save etcher-image-stream
- imageStream
- .supportedFileTypes :
Array.<String>
- .getFromFilePath(file) ⇒
Promise
- .getImageMetadata(file) ⇒
Promise
- .supportedFileTypes :
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);
});
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'));
});
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}`);
});
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:
$ npm test
- Issue Tracker: github.com/resin-io-modules/etcher-image-stream/issues
- Source Code: github.com/resin-io-modules/etcher-image-stream
Before submitting a PR, please make sure that you include tests, and that jshint runs without any warning:
$ npm run lint
etcher-image-stream
is free software, and may be redistributed under the terms specified in the license.