hypercore-blob-server provides an HTTP server specifically designed for streaming data (blobs and files) from Hypercore and Hyperdrive instances. It allows applications to expose content from the peer-to-peer Holepunch ecosystem over standard HTTP, making it accessible to traditional web clients or tools. Currently at version 1.12.0, it is an actively developed part of the Holepunch (formerly Dat Project) ecosystem, offering a more flexible successor to 'serve-drive'. The package differentiates itself by tightly integrating with Corestore for data management, supporting partial content delivery via HTTP Range headers, and generating direct links for both raw Hypercore blobs and Hyperdrive files, facilitating interoperability between decentralized data structures and conventional web infrastructure.
npm install hypercore-blob-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates the full flow of initializing a Corestore, creating a Hypercore, appending data, starting a BlobServer, and generating a shareable link to the content.
Ensure `const store = new Corestore('./path/to/data'); await store.ready()` is called and awaited before passing the `store` instance to `BlobServer`.Configure the `token` option in the `BlobServer` constructor: `new BlobServer(store, { token: process.env.BLOB_SERVER_TOKEN })`. Clients will then need to pass this token in request headers for authorization.Validate client `Range` header syntax and ensure byte offsets are within the blob's actual bounds. Ensure no spaces or invalid characters are present.
Ensure the `blob` object accurately describes the segment of data within the Hypercore. This often requires careful tracking of data appended to the core, or using library utilities to derive these values.
Initialize `Corestore` correctly and ensure `await store.ready()` has been called: `const Corestore = require('corestore'); const store = new Corestore('./data-path'); await store.ready();`Change the `port` option in the `BlobServer` constructor to an available port (e.g., `port: 0` to let the OS assign a random available port), or terminate the process currently using the desired port.
Verify that the `key` is correct, the associated Hypercore/Hyperdrive has been opened and contains data, and the `blob` or `filename` parameters precisely match the content intended to be served.
Adjust the `Range` header to request valid byte ranges within the blob's actual size. Ensure the header format is strictly `bytes=<start>-<end>` (e.g., `Range: bytes=0-500`).