@chunkd/source-http
TypeScript icon, indicating that this package has built-in type declarations

11.1.0 • Public • Published

@chunkd/source-http

Load a chunks of a file from a HTTP(s) Source using fetch

Usage

import { SourceHttp } from '@chunkd/source-http';

const source = new SourceHttp(new URL('https://example.com/cog.tif'));

const firstBuffer = await source.fetchBytes(0, 1024); // Load the first 1KB from the source
const lastBuffer = await source.fetchBytes(-1024); // load the last 1KB from the source

const size = source.metadata?.size; // File size if metadata has been fetched

Relative URLs

for relative urls, use document.baseURI

const source = new SourceHttp(new URL('../cog.tif', document.baseURI));

Advanced Usage

For caching, block alignment and fetch grouping see @chunkd/middleware and @chunkd/fs

Nodejs <18

Node.js <18 does not come with a default fetch function, a fetch method must be provided before being able to be used.

import { SourceHttp } from '@chunkd/source-http';
import { fetch } from 'node-fetch';

SourceHttp.fetch = fetch;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
11.1.0476latest

Version History

VersionDownloads (Last 7 Days)Published
11.1.0476
11.0.22
11.0.12
11.0.00
10.1.240
10.1.17
10.1.00
10.0.21
10.0.04
8.4.01
8.3.00
8.2.00
8.1.00
8.0.30
8.0.20
8.0.10
7.2.40
7.2.30
7.2.20
7.2.00
7.1.00
7.0.10
7.0.00

Package Sidebar

Install

npm i @chunkd/source-http

Weekly Downloads

439

Version

11.1.0

License

MIT

Unpacked Size

21.2 kB

Total Files

10

Last publish

Collaborators

  • blacha