Skip to main content

StorageChunkSource

StorageChunkSource is an advanced implementation of ChunkSource that retrieves chunks from a StorageAdapter.
It allows two types of access:

  • HashStorageAdapter — retrieves chunks from hash.
  • UrlStorageAdapter — retrieves chunks using urls, using optional urlsMap.

It is the ideal option when chunks comes from remote servers, CDNs, S3 buckets or other storage backends.

The StorageChunkSource will be automatically created by pipelines, or manually created using:

racDeltaClient = await RacDeltaClient.create({...});

const chunkSource = new StorageChunkSource(racDeltaClient.storage);

Constructor

ParameterTypeDescription
storageStorageAdapterAdapter that defines how and from where chunks are retrieved.
urlsMapMap<string,string>Required when using UrlStorageAdapter. Maps hash -> URL

Methods

MethodReturnsDescription
getChunk(hash)Promise<Buffer>Returns a single chunk by its hash.
getChunks(hashes, options?)Promise<Map<string, Buffer>>Fetch multiple chunks concurrently.
streamChunks(hashes, options?)AsyncGenerator<{ hash: string; data: Readable }>Stream chunks, possibly preserving order.