Accessing Uploads and Results

Working with uploaded files

To upload a file to your Nextjournal notebook, simply drag it into your browser window or click the + button between nodes and select File…

Once your file has been uploaded, Nextjournal will move it to a special location so that it can be versioned efficiently together with your notebook’s contents and can be referenced from any code cell (no matter the language it uses). Simply press Cmd/Ctrl+E in your code cell or select some code, click the + button in the selection toolbox and select the file you want to work with. This will insert a reference to your previously uploaded file:

Working with results

Files that result from running your code can be referenced in the same way that an uploaded file can. There is a special directory called /results that’s available from any code cell. Once you write to it, the file is moved to a special location so it’s versioned and can be referenced.

Please note that /results can only be written to. It’s main purpose is to provide files so that they can be referenced.

The same principles apply to reference resulting files. If a code cell ran successfully and it shows a file result below it, that file can be referenced by pressing Cmd/Ctrl+E or by clicking the + button after selecting some code.

To illustrate this, here is a Bash code cell that writes some text to a file:

echo "Hi! 👋" > /results/test.txt
empty

… and here is another Bash cell that references the resulting file:

cat 
test.txt

Limitations & Workarounds

Some tools require that resulting files live in a specific directory or have specific names in order to work properly. This can be problematic, because the paths underlying a referenced file are automatically assigned by Nextjournal and can’t be customized at the moment:

ls 
test.txt

The good news is, you can use symlinks to work around this. Let’s say you have a tool that requires your files to have a certain extension or to exist in a certain directory, you can simply create that directory and symlink it to whatever you need:

mkdir -p /analysis

# Create symlink unless it already exists
[ -f /analysis/input-1.ipt ] || ln -s 
test.txt
/analysis/input-1.ipt ls /analysis/input-1.ipt

Note: We are aware that this is cumbersome at the moment but we’re already at work building a better solution to address this.