Code Monkey home page Code Monkey logo

etcher-image-stream's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.