Skip to main content

UrlStorageAdapter

UrlStorageAdapter defines the contract for any storage backend that stores chunks accessed by url.
It extends StorageAdapter.

This class is abstract; real implementations belong to the infrastructure layer and are not used directly by consumers of the SDK.


Properties

NameTypeDescription
type"url"Identifies the adapter category.

Methods

MethodReturnsDescription
getChunkByUrl(url)Promise<Readable | null>Retrieve a chunk stream by url.
putChunkByUrl(url, data)Promise<void>Upload a chunk from a readable stream by url.
chunkExistsByUrl(url)Promise<boolean>Check whether a chunk exists via url.
deleteChunkByUrl(url)Promise<void>Delete a chunk via url.
listChunksByUrl?(url)Promise<string[]>Optional: list stored chunk hashes by url.
getChunkInfoByUrl?(url)Promise<BlobInfo | null>Optional: return chunk metadata via url.
getRemoteIndexByUrl(url)Promise<RDIndex | null>Retrieve remote rd-index.json by url
putRemoteIndexByUrl(url, index)Promise<void>Upload remote rd-index.json by url

Method details

getChunkByUrl(url)

Retrieve a readable stream of a chunk, or null if the chunk is not present by url.

Parameters

NameTypeDescription
urlstringUrl that will be used to retrieve desired chunk

Returns

Promise<Readable | null>


putChunkByUrl(url, data)

Upload a chunk by url.

Parameters

NameTypeDescription
urlstringUrl to upload chunk
dataReadableSource data stream

Returns

Promise<void>


chunkExistsByUrl(url)

Check if a chunk exists by url.

Parameters

NameTypeDescription
urlstringUrl to check if chunk exists

Returns

Promise<boolean>


deleteChunkByUrl(url)

Deletes a chunk by url if exists.

Parameters

NameTypeDescription
urlstringUrl to delete chunk

Returns

Promise<void>


listChunksByUrl?(url)

Retrieves a list of chunk hashes by url. Optional method.

Parameters

NameTypeDescription
urlstringUrl to list chunks

Returns

Promise<string[]>


getChunkInfoByUrl?(url)

Retrieves metadata of given chunk by url. Optional method.

Parameters

NameTypeDescription
urlstringUrl to get chunk info

Returns

Promise<BlobInfo | null>

export interface BlobInfo {
hash: string;
size: number;
modified?: Date;
metadata?: Record<string, string>;
}

getRemoteIndexByUrl(url)

Retrieves remote rd-index.json from given url.

Parameters

NameTypeDescription
urlstringUrl to get index

Returns

Promise<RDIndex | null>


putRemoteIndexByUrl(url, index)

Uploads a rd-index.json to storage by url.

Parameters

NameTypeDescription
urlstringThe url to upload index
indexRDIndexThe rd-index object

Returns

Promise<void>