Skip to main content

downloadFiles()

downloadFiles(request: DownloadFilesRequest): Promise<Blob>

Defined in: packages/core/src/index.ts:1938

Download files by path

Parameters

ParameterTypeDescription
requestDownloadFilesRequestDownload request with object_path (format: sourceName/filename)

Returns

Promise<Blob>

Blob containing the binary file data

Throws

401 - Not authenticated

Throws

404 - File not found

Example

import { downloadFiles } from "@cpod/sdk";

// Download file and create download link
const blob = await downloadFiles({
object_path: "source-name/document.pdf"
});

// Create download URL in browser
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'document.pdf';
a.click();
URL.revokeObjectURL(url);