Get a File Stream of a Data Table
Get a stream of the contents of an exported data table, in CSV (default) or Excel format.
Permissions Required
You must have View permissions to the field this file was uploaded to for this request to succeed
Method Signature
DownloadStream GetFileStream(Guid id, DataTableExportFormat format);
async Task<DownloadStream> GetFileStreamAsync(Guid id, DataTableExportFormat format);
Parameters
Parameter | Type | Description |
---|---|---|
id | Guid | The id of the Data Table to get a readable stream of |
format | DataTableExportFormat | CSV or Xlsx (Excel) |
returns | DownloadStream | The requested file's metadata and readable stream |
DownloadStream GetFileStream(string id, DataTableExportFormat format);
async Task<DownloadStream> GetFileStreamAsync(string id, DataTableExportFormat format);
Parameter | Type | Description |
---|---|---|
id | string | The id of the Data Table to get a readable stream of |
format | DataTableExportFormat | CSV or Xlsx (Excel) |
returns | DownloadStream | The requested file's metadata and readable stream |
Stream Disposal
DownloadStream
implementsIDisposable
. Be sure to wrap calls in ausing
statement, or callDispose()
directly when you are done reading the stream. See the example below.
Example
/*
* This example demonstrates streaming a Data Table's contents to
* the Console as CSV rows
*/
using Catalytic.Sdk.Entities;
namespace Catalytic.Sdk.Examples
{
class Program
{
static void Main(string[] args)
{
var catalytic = new Catalytic.Sdk.CatalyticClient(Credentials.Default);
using (var file = catalytic.DataTables.GetFileStream(
"8d20bdf5-d3bb-4a08-b05b-eb22a8b5c300",
DataTableExportFormat.CSV))
{
Console.WriteLine($"Name: ${file.FileName}");
Console.WriteLine($"Size (bytes): ${file.Size}");
Console.WriteLine($"Content-Type: ${file.ContentType}");
Console.WriteLine("Content:\n----");
while (!file.Stream.EndOfStream)
{
Console.WriteLine(file.Stream.ReadLine());
}
}
}
}
}
Updated almost 3 years ago