0.2.2 • Published 4 years ago

fs-read-stream-over-http v0.2.2

Weekly downloads
28
License
ISC
Repository
github
Last release
4 years ago

fs-read-stream-over-http

Deprecated in favor of stream-http.


Isomorphic fs.createReadStream. Delegates to core fs in Node, uses the Browserify http shim in the browser.

npm version build status ISC-licensed chat on gitter

Installing

npm install fs-read-stream-over-http

Usage

You need to provide a function that maps local paths such as ./foo/bar.txt to a URL:

const path = require('path')

const pathToUrl = local => 'https://example.org' + path.resolve('/', local)

It will be used in the browser, to fetch the file over HTTP. In Node, the local path will be used.

const fsCreateReadStream = require('fs-read-stream-over-http')

fsCreateReadStream('/foo/bar.txt', pathToUrl, {encoding: 'utf8'})
.on('data', console.log)
.once('end', () => console.log('end!'))

fsCreateReadStream will throw when called with options that can't be fulfilled in the browser (e.g. flags). Otherwise it will return a stream of decoded data.

Contributing

If you have a question or have difficulties using fs-read-stream-over-http, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

0.2.2

4 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago