Files
Create and use files within tasks
Files can be used to pass large amounts of data between tasks. Certain file types can be displayed
directly in the UI, such as images, videos, audio, text, or CSVs (see
File displays).
Creating files
Creating files
Users can upload files directly to Airplane via task parameters or
prompt inputs. When doing so, they will be greeted with a file input form:

Files can also be directly created within a task via the file uploads API. For example, you can
download the source code for Airplane's website and upload it as a file:
typescriptCopied1const resp = await fetch("https://airplane.dev");23const myFile = airplane.file.upload(await resp.text(), "airplane.txt");45// you can display the file directly in the UI6await airplane.display.file(myFile);78// you can also pass the file to another task9await airplane.execute("my_task", { file: myFile });
pythonCopied1resp = requests.get("https://airplane.dev")23my_file = airplane.files.upload(resp.content, "airplane.txt")45# you can display the file directly in the UI6airplane.display.file(my_file)78# you can also pass the file to another task9airplane.execute("my_task", { "file": myFile })
Limitations
Limitations
- Maximum file size is 2Gb.
- File URLs expire after 7 days. This may be relevant if you are using a file's URL directly, e.g. sending an email with the URL.
Examples
Examples
Passing a large SQL request into another task
Passing a large SQL request into another task
typescriptCopied1const run = await airplane.sql.query("db", "select * from customers");23// Without creating the file, the SQL result might be too large to pass directly to another task.4const customerData = await airplane.file.upload(5JSON.stringify(run.output.Q1),6"customer_data.json",7);89// processData is a task that takes a file as input.10await processData({ data: customerData });
pythonCopied1run = airplane.sql.query("db", "select * from customers")23# Without creating the file, the SQL result might be too large to pass directly to another task.4customer_data = airplane.files.upload(json.dumps(run.output["Q1"]), "customer_data.json")56# process_data is a task that takes a file as input.7process_data(customer_data)
Upload a CSV file, change the column names to uppercase, and display the results
Upload a CSV file, change the column names to uppercase, and display the results
typescriptCopied1import airplane from "airplane";2// From https://www.npmjs.com/package/csv-parse3import { parse } from "csv-parse/sync";45export default airplane.task(6{7slug: "display_csv",8parameters: {9csv_upload: "upload",10},11},12async (params) => {13// Download from URL into memory.14const response = await fetch(params.csv_upload.url);1516// Open the file as a CSV.17const parsedCSV = parse(await response.text());1819// Convert the column names to uppercase.20const processedCSV = parsedCSV.map((row: string[], i: number) => {21if (i === 0) {22return row.map((col) => col.toUpperCase());23}24return row;25});2627// Upload the new CSV.28const processedCSVFile = await airplane.file.upload(processedCSV.join("\n"), "processed.csv");2930// Display the new CSV.31await airplane.display.file(processedCSVFile);32},33);
pythonCopied1import csv2import io3import requests45import airplane67@airplane.task()8def display_csv(csv_upload: airplane.File):9# Download from URL into memory.10response = requests.get(csv_upload.url)1112# Open the file as a CSV.13parsed_csv = csv.reader(io.StringIO(response.text))1415# Convert the column names to uppercase.16processed_csv = []17for i, row in enumerate(parsed_csv):18if i == 0:19row = [col.upper() for col in row]20processed_csv.append(",".join(row))2122# Upload the new CSV.23processed_csv_file = airplane.files.upload("\n".join(processed_csv), "processed.csv")2425# Display the new CSV.26airplane.display.file(processed_csv_file)
SDK reference
SDK reference
See File SDK reference for more information.