https://github.com/e-e-e/http-random-access
A random access interface for files served over http
https://github.com/e-e-e/http-random-access
Last synced: 8 months ago
JSON representation
A random access interface for files served over http
- Host: GitHub
- URL: https://github.com/e-e-e/http-random-access
- Owner: e-e-e
- Created: 2017-10-22T04:14:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T22:14:24.000Z (about 8 years ago)
- Last Synced: 2025-06-09T17:16:15.650Z (9 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# http-random-access
[](https://travis-ci.org/e-e-e/http-random-access) [](https://coveralls.io/github/e-e-e/http-random-access?branch=master)
**This module is deprecated - its has been functionally merged with [random-access-http](https://www.npmjs.com/package/random-access-http). Please use it instead.**
An implementation of [random-access-storage](https://www.npmjs.com/package/random-access-storage) to access content via http/s.
Providing the same interface as [random-access-file](https://www.npmjs.com/package/random-access-file) and [random-access-memory](https://www.npmjs.com/package/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
```js
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:
```js
{
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.