2.0.0 • Published 6 years ago
http-random-access v2.0.0
http-random-access
This module is deprecated - its has been functionally merged with random-access-http. Please use it instead.
An implementation of random-access-storage to access content via http/s. Providing the same interface as random-access-file and random-access-memory. This implementation is intended as a drop-in replacement for random-access-file or random-access-memory in the dat-storage configuration.
Installation
npm install http-random-access --save
Basic Example
var raHttp = require('http-random-access')
var file = raHttp('/readme.md', { url: 'https://raw.githubusercontent.com/e-e-e/http-random-access/master/' })
file.read(100, 200, (err, data) => {
if (err) {
console.log('Something went wrong!')
console.log(err)
return
}
console.log(data.toString())
})
API
var file = raHttp(file, options)
Open a new random access http file connection.
Options include:
{
url: string // The url of the dat
verbose: boolean, // Optional. Default: false.
}
file.read(offset, length, callback)
Read a buffer at a specific offset of specified length. Callback is called with the read buffer or error if there was an error.
Expects callback of the form function (err, result) {}
.
file.write(offset, buffer, callback)
Write is not implemented. This will silently fail with no data being writen.