Accessing Uploads and Results

In this guide, we'll show you how to upload data into your notebook, how to reference it from your code cells, and how to work with the results that you generate in your notebook.

How to upload a file

To upload a file up to 500 MB to your Nextjournal notebook, drag and drop it into your notebook:

Alternatively, click the “+” button (or press Ctrl/Cmd E) below a block and select the File… option.

How to reference a 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. It also can be referenced from any code cell (no matter its language).

To do so, when in your code cell press Shift Cmd/Ctrl E , or click on Reference file, as suggested in your Command Bar at the bottom of your screen. This will show you the list of files that you've uploaded, and you can select the one you want:

How to persist, and reference your results

All filesystems associated to each runtime are transient. This means that, once the runtime shuts down or you reset it, all results that you have obtained using the code cells are lost and all cells will have to be re-run to re-generate their results.

If you want to persist and version your results, make sure you write the code cell output to a special Nextjournal directory called /results. Any files placed there are moved into versioned storage, and can be referenced in the same way as the uploaded files.

Therefore, if a code cell has run successfully and shows a file result below it, you can reference the file 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 the file test.txt:

echo "Hi! 👋" > /results/test.txt
0.2s

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

cat test.txt
1.2s

Downloading your results

If you'd like to download your generated files, make sure to change your result viewer type to a file through from the Block Options of the code cell that generates your file:

Then, press the Download button appearing on the file.

Uploading files larger than 500 MB

Saving to /results is also how you can get files larger than 500 MB into a notebook. Using the curl or wget tools in a Bash cell, you can download files from websites, repositories, and cloud storage like Dropbox.

Below we have a cell that downloads the three parts of the Stanford Street View House Number dataset —1.5 GB altogether.

wget --progress=dot:giga -P /results \
  http://ufldl.stanford.edu/housenumbers/{train,test,extra}_32x32.mat
105.1s

Note that we locked the cell after downloading, so it will not run again.

⚠️ : /results can only be written to. Its purpose is to store files so that they can be referenced, as well as attempting to display files in supported formats.

Directories, Linking, and Copying

Filenames are preserved when saving to /results; however, some tools require that files reside in a specific directory structure in order to work properly. You can use symlinks to efficiently achieve this, by creating the directory structure, and then linking to the stored files.

The following would allow the TFLearn neural network library to find the dataset downloaded above:

mkdir -pv svhn
ln -sfv train_32x32.mat svhn/
ln -sfv test_32x32.mat svhn/
ln -sfv extra_32x32.mat svhn/
1.1s

Sometimes you will need read-write access to open a datafile, or want to make changes and re-save. You can use cp in a Bash cell, or any in-language file copying function to copy files from storage into the local filesystem.

# copy file if missing
[ -f /test.txt ] || cp -v test.txt /
ls -l test.txt
0.7s

Modified data files can then be copied back into /results to for saving and versioning.

Runtimes (1)