You can upload and download files to and from the Catalytic platform. You can then reference those files in Fields in Workflows and Instances.

The Files client allows you to upload and download files from the Catalytic platform, and to get file metadata like size, content-type and filename. It provides the following methods:

MethodDescription
getGets metadata of a File by id
findSearch for Files by name, workflowId or instanceId
downloadDownloads a File by id
uploadUploads a new File

Quickstart Example

<?php

/*
 * This example demonstrates downloading and uploading files
 * from a Workflow Instance.
 */

require_once(__DIR__ . '/vendor/autoload.php');

use Catalytic\SDK\CatalyticClient;

// create and initialize the Catalytic SDK Client
$catalytic = new CatalyticClient();

// Find workflows matching "Sdk Example Workflow"
$where = (new Where())->text()->matches("Sdk Example Workflow");

// `results` is a results page containing `workflows` and 
// a `nextPageToken` you can use to page through results.
$results = $catalytic->workflows()->find($where);

// Get the workflows from the $results
$workflows = $results->getWorkflows();

// If Workflows were found, get the first one
if ($workflows) {
	$workflow = $workflows[0]; 		
}
// If no Workflows were found, let's import one
else {
  $workflow = $catalytic->workflows()->import(new SplFileObject("https://push.bot/sdk-example"));
}

// Now that we've got our Workflow, let's start an Instance with inputs it expects
$instance = $catalytic->instances()->start(
  $workflow->getId(),
  'SDK Example',
  'My first SDK example',
  array('Age' => 42, 'Name' => 'Alice')
);

// Find workflows matching "Sdk Example Workflow"
$where = (new Where)->text()->matches("Sdk Example Workflow");
$results = $catalytic->workflows()->find($where);

// Get the steps
$steps = $catalytic->instances->getSteps($instance->getId())->getSteps();

// Get the step we want to complete
$uploadStep = array_filter($steps, function ($value, $key) {
   return $key === 'name' && $value === "Upload Updated Spreadsheet and Set Email";
})[0];
            
// Download the Data Table from the "Table" field as a CSV 
$tableId = $instance->getFields["Table"]->getValue();
$csvFile = $catalytic->dataTables()->download($tableId, 'csv');

// Do our "business logic" to transform the csv data
// As a simple example, we replace "Foo" with "Bar"
$updatedCsvContent = csvFile->OpenText()->ReadToEnd()->Replace("Foo", "Bar");

// Create the output csv file locally
$updatedCsvFile = new SplFileObject(sys_get_temp_dir(), 'w');

$updatedCsvFile.fwrite($updatedCsvContent);

// To complete the step, we will set both a text and a file field
$stepRequest = $step
		->SetInput("Updated CSV", updatedCsvFile)
		->SetInput("Email Address", YourEmail);

$catalytic->instances()->completeStep();

echo "You should have an email waiting for you at $yourEmail now ", 
		 "with the updated CSV converted to an Excel attachment");