Skip to content
Local environment Preproduction — not production data

Factorial Code Storage

Factorial Code Storage is a robust file storage system designed to handle file operations within your processes. It provides a simple and efficient way to store, retrieve, and manage files through accessible source code integration.

With Factorial Code Storage, you can perform various file operations including:

  • File Upload: Store files from your processes or external sources
  • Automatic Form Uploads: Receive files submitted from input-parameter forms directly in storage
  • File Download: Retrieve files for processing or analysis
  • File Management: List and delete your stored files
  • Signed URLs: Generate temporary download URLs for existing files

Factorial Code Storage is perfect for scenarios such as:

  • Document Processing: Store uploaded documents for analysis or transformation
  • Image Processing: Handle image files for resizing, conversion or analysis
  • Data Export: Generate and store reports, CSV files or other exports
  • File Sharing: Create temporary file storage for sharing between processes
  • Backup Operations: Store important files as part of backup workflows

Automatic Uploads from Input Parameter Forms

Section titled “Automatic Uploads from Input Parameter Forms”

When your process uses an input parameter form with file fields ("ui:widget": "file"), Factorial Code uploads those submitted files to storage automatically before execution starts.

Inside your process code, file parameters become storage references you can use with fcode.storage.download() and other storage methods.

For one file field, you receive one storage path. If your form allows multiple files, you will receive an array of storage paths.

Download a file submitted through a form
const {
context: { parameters },
} = fcode;
const uploadedPath = parameters.inputFile;
// Upload path starts with "fcode.storage://"
const fileStream = await fcode.storage.download(uploadedPath.replace("fcode.storage://", ""));

Factorial Code Storage can be accessed through multiple methods, making it flexible for different use cases and integration scenarios:

The most direct way to use Factorial Code Storage is from within your process source code using the fcode.storage helper:

Uploading a file
const path = require("node:path");
const localPath = path.join(process.env.TMP_DATA_DIR, "myfile.txt");
await fcode.storage.upload("path/myfile.txt", fs.createReadStream(localPath));
Listing files
const files = await fcode.storage.list();
console.log(files);
Downloading a file
const path = require("node:path");
const localPath = path.join(process.env.TMP_DATA_DIR, "downloaded.txt");
const stream = await fcode.storage.download("path/myfile.txt");
stream.pipe(fs.createWriteStream(localPath));
Deleting a file
await fcode.storage.delete("path/myfile.txt");
Creating a signed URL
const signed = await fcode.storage.createSignedUrl("path/myfile.txt");
console.log(signed.url, signed.expiresAt);
const signedWithCustomExpiry = await fcode.storage.createSignedUrl("path/myfile.txt", {
expiresInSeconds: 900,
});
console.log(signedWithCustomExpiry.url, signedWithCustomExpiry.expiresAt);

Factorial Code Storage is also available through our REST API, allowing you to upload, download, list, delete, and create signed URLs from any external system. This enables integration with third-party applications, web services, or any system that can make HTTP requests.

You can interact with Factorial Code Storage from external applications using our Factorial Code Run SDK, available for both JavaScript and Python:

Using Factorial Code Run SDK for JavaScript
const { FcodeStorage } = require('@factorialco/fcode-sdk');
const fs = require('fs');
const storage = new FcodeStorage({ apiToken: 'your-api-token' });
// Upload a file (using Node.js stream)
await storage.upload('path/myfile.txt', fs.createReadStream('./myfile.txt'));
// List files
const files = await storage.list();
console.log(files);
// Download a file
const stream = await storage.download('path/myfile.txt');
stream.pipe(fs.createWriteStream('./downloaded.txt'));
// Delete a file
await storage.delete('myfile.txt');
// Create a temporary signed URL (default expiration ~1 hour)
const signed = await storage.createSignedUrl('path/myfile.txt');
console.log(signed.url, signed.expiresAt);
// Custom expiration
const signedWithCustomExpiry = await storage.createSignedUrl('path/myfile.txt', {
expiresInSeconds: 900,
});
console.log(signedWithCustomExpiry.url, signedWithCustomExpiry.expiresAt);

Install the SDK: pnpm install @factorialco/fcode-sdk

Factorial Code Storage is available as MCP (Model Context Protocol) tools in our MCP server, making it incredibly powerful when combined with AI agents. This enables AI agents to:

  • Handle file-based tasks end-to-end without manual intervention
  • Process complex data using the full power of Python/JavaScript ecosystems
  • Store and retrieve results securely in the cloud
  • Chain multiple operations across different files and datasets

When combined with our run_code tool, AI agents can upload files, generate and execute code to process them, and store results back to Factorial Code Storage automatically.

Factorial Code Storage works seamlessly with local disk for comprehensive file handling workflows. This combination is particularly useful when you need to:

  • Process files that require specific file paths or libraries that don’t support streams
  • Perform complex data transformations that benefit from local file access
  • Handle large files that need to be processed in chunks