File
Allows you to upload a file to Airplane.
Airplane's SDKs make it easy to interact with files from your tasks and views.
To learn more about using files in Airplane, see Files documentation.
Upload
Upload
Create a file that can be passed to other tasks as a file parameter,
rendered as a file display, or returned as task output.
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 });
airplane.file.upload(payload, fileName)
payload
REQUIRED
Content of the file to upload.
fileName
optional
Name of the file to create. If not provided, the filename will be generated by trying to infer the file type from the payload. If the file type cannot be inferred, an error will be raised.
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 })
airplane.file.upload(payload, file_name)
payload
REQUIRED
Content of the file to upload.
file_name
optional
Name of the file to create. If not provided, the filename will be generated by trying to infer the file type from the payload. If the file type cannot be inferred, an error will be raised.
Returns
An Airplane File object.
Raises
If the file could not be uploaded.
If the file type could not be inferred and no filename was provided.