PermuteDocs
Go to Permute

Guide

Upload and process a file

Create a file dataset, PUT the bytes to its signed S3 target, and poll while processing runs automatically. CSV, TSV, JSON, NDJSON, and Parquet files can be up to 1 GiB; other supported file types can be up to 100 MiB. Permute applies the limit from contentType.

Workflow

  1. 1Create the file dataset
  2. 2PUT bytes to S3
  3. 3Let processing start automatically
  4. 4Poll until completed

Complete example

typescript
import { readFile } from 'node:fs/promises';
import { PermuteClient } from '@permute/sdk';

const orgClient = new PermuteClient({
  apiKey: process.env.PERMUTE_API_KEY!,
});
const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);

const bytes = await readFile('./revenue.csv');
const dataset = await client.datasets.create({
  type: 'file',
  fileName: 'revenue.csv',
  contentType: 'text/csv',
  data: bytes, // The SDK infers sizeBytes.
});

while (dataset.status !== 'completed' && dataset.status !== 'failed') {
  await new Promise((resolve) => setTimeout(resolve, 2000));
  await dataset.refresh();
}

if (dataset.status === 'failed') throw new Error(dataset.data.error ?? 'Dataset processing failed');
console.log(dataset.data);