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

ParameterTypeDescription
idGuidThe id of the Data Table to get a readable stream of
formatDataTableExportFormatCSV or Xlsx (Excel)
returnsDownloadStreamThe requested file's metadata and readable stream
DownloadStream GetFileStream(string id, DataTableExportFormat format);
async Task<DownloadStream> GetFileStreamAsync(string id, DataTableExportFormat format);
ParameterTypeDescription
idstringThe id of the Data Table to get a readable stream of
formatDataTableExportFormatCSV or Xlsx (Excel)
returnsDownloadStreamThe requested file's metadata and readable stream

šŸš§

Stream Disposal

DownloadStream implements IDisposable. Be sure to wrap calls in a using statement, or call Dispose() 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());
                }
            }
        }
    }
}