multiblob-http is a Node.js library designed to serve content-addressed blobs over HTTP. It provides an HTTP handler, compatible with frameworks like Express, that exposes endpoints for retrieving blobs by hash (`GET /blobs/get/{id}`) and adding new blobs (`POST /blobs/add`). The library ensures efficient content delivery by setting appropriate HTTP headers, including `ETag` (based on the blob hash) and `Expires` (a year in the future), and supports HTTP range requests (RFC 7233) crucial for streaming media and partial content retrieval. The current stable version is 1.2.1, with releases appearing to follow a maintenance cadence, focusing on stability rather than frequent new features. Its primary differentiator is its tight integration with the `multiblob` package for backend storage and its robust handling of HTTP caching mechanisms for immutable, content-addressed data.
npm install multiblob-httpVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic `multiblob-http` server to serve content-addressed blobs from a local directory, demonstrating how to initialize the server and programmatically add a blob.
For ESM projects, use `import MultiBlobHttp from 'multiblob-http'`. If issues arise, consider configuring your bundler (e.g., Webpack, Rollup) or `tsconfig.json` for proper CJS module resolution.
Install `multiblob` via `npm install multiblob` or `yarn add multiblob`. Always pass a correctly initialized `multiblob` instance to `MultiBlobHttp()`.
Ensure your Node.js version is at least 12. If running on much newer Node.js versions (e.g., Node.js 18+), monitor for unexpected behavior or deprecated APIs, though a simple HTTP handler is less prone to such issues.
Clients should only use `POST /add` and rely on the server's response for the generated hash. Avoid sending a hash in the URL for `POST /add` as it will be ignored for validation purposes in the current implementation.
Install `multiblob` (`npm install multiblob`) and ensure it's imported correctly: `const MultiBlob = require('multiblob')` or `import MultiBlob from 'multiblob'`.Choose a different port for your HTTP server, or identify and terminate the process currently using the port.
Verify the hash is correct and corresponds to an existing blob. Check that the `prefix` argument passed to `MultiBlobHttp(blobs, '/blobs')` matches the URL path you are requesting (e.g., `/blobs`).
Convert `require('multiblob-http')` to `import MultiBlobHttp from 'multiblob-http'` (and similarly for `multiblob`) if your project is ESM-first. Ensure your `package.json` has `"type": "module"` if using `.js` files as ESM.