@cessnetwork/api
Version:
CESS Chain Interface Implementation in TypeScript
63 lines • 2.4 kB
TypeScript
import { DownloadOptions, FetchDataOptions, GatewayConfig, QueryDataOptions, UploadResponse } from "@cessnetwork/types";
export interface ExtendedDownloadOptions extends DownloadOptions {
savePath?: string;
createDirectories?: boolean;
overwrite?: boolean;
range?: {
start: number;
end?: number;
};
encryption?: {
capsule: string;
rkb: string;
pkx: string;
};
}
export interface DownloadResult extends UploadResponse {
data?: {
content?: ArrayBuffer;
contentType?: string | null;
contentLength?: string | null;
contentRange?: string | null;
filePath?: string;
fileName?: string;
fileSize?: number;
isPartialContent?: boolean;
};
}
export declare const GATEWAY_GETFILE_URL = "/gateway/download";
export declare const RETRIEVER_QUERYDATA_URL = "/querydata";
export declare const RETRIEVER_FETCHDATA_URL = "/cache-fetch";
/**
* Download file from gateway with optional save to disk
*/
export declare function downloadFile(config: GatewayConfig, options: ExtendedDownloadOptions): Promise<DownloadResult>;
/**
* Download file with range request support (useful for resuming downloads)
*/
export declare function downloadFileRange(config: GatewayConfig, options: ExtendedDownloadOptions, start: number, end?: number): Promise<DownloadResult>;
/**
* Download encrypted file
*/
export declare function downloadEncryptedFile(config: GatewayConfig, options: ExtendedDownloadOptions, encryptionData: {
capsule: string;
rkb: string;
pkx: string;
}): Promise<DownloadResult>;
/**
* Fetch file metadata without downloading content
*/
export declare function getFileMetadata(config: GatewayConfig, options: DownloadOptions): Promise<UploadResponse>;
/**
* Download file with progress tracking and support for range requests
*/
export declare function downloadFileWithProgress(config: GatewayConfig, options: ExtendedDownloadOptions, onProgress?: (downloaded: number, total: number) => void): Promise<DownloadResult>;
/**
* Query data from retriever
*/
export declare function queryData(config: GatewayConfig, options?: QueryDataOptions): Promise<UploadResponse>;
/**
* Fetch data from cache
*/
export declare function fetchCacheData(config: GatewayConfig, options: FetchDataOptions): Promise<UploadResponse>;
//# sourceMappingURL=download.d.ts.map