Get a File Stream
Get a metadata and a readable stream of the contents of a File.
Permissions Required
You must have View permissions to the field this file was uploaded to for this request to succeed
Method Signature
getDownloadStream(id: string): Promise<Stream>;
getDownloadStream(id: string, callback: (err?: Error, stream: Stream) => any): void;
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The id of the File to get a readable stream of |
callback | (err?: Error, stream: Stream) => any | Optional The callback |
returns | Stream | The requested file's metadata and readable stream |
Example
/*
* This example demonstrates streaming a File's contents to
* the Console
*/
const { CatalyticClient } = require('@catalytic/sdk');
const catalytic = new CatalyticClient();
const stream = await catalytic.files.getDownloadStream('c9f2beec-10c0-4f2f-b4e0-1d884c7e053c');
stream.on('data', chunk => console.log(chunk.toString()));
Updated almost 3 years ago