read-webfile
read a file from a url just like from a file path!
Installation
npm i read-webfile --save
wf.readFileFromWeb(path[, options], callback)
basicly, this function is design to follow native API of fs.readFile.
-
path
<string>
|<URL>
required- can be a string such as
https://nodejs.org
- can be a URL object such as
new URL('https://nodejs.org')
- is required, and only support http or https portocol
- can be a string such as
-
options
<Object>
|<string>
- can be a string which represent encoding such as 'utf8'
- can be object such as
{encoding: 'utf8'}
-
callback
<Function>
- err
<Error>
- data
<string>
|<Buffer>
- err
const wf =let url = 'https://nodejs.org/en/'wf
wf.createReadStream(path[, options])
basicly, this function is design to follow native API of fs.createReadStream.
- path
<string>
|<URL>
- options
<string>
|<Object>
- encoding
<string>
Default: null
- encoding
- Returns: a Readable Stream.
const wf =let url = 'https://nodejs.org/en/'const rs = wfrsrs1
notice
this function can not handler redirect such a http 304 code.