Files
You can upload files to use in your Napkin functions. Go to the Other
tab in the Napkin editor and scroll down to Files
. You can upload any file as long as its size is less than 1MB.
Once uploaded, your function can access your files via the /opt/files
directory. You can access your files using the usual built-in modules for both Javascript and Python. For example, assuming you've uploaded a file called file.txt
, here's how you can print the contents of the file:
import fs from "fs";
const data = fs.readFileSync("/opt/files/file.txt", "utf-8");
console.info(data);