Accessing Uploads and Results
Working With Uploaded Files
To upload a file up to 500 MB 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
/results
Files that result from running your code can be referenced in the same way that an uploaded file can. The special directory /results
is available from any code cell. Any files placed there are moved into versioned storage, and can be referenced.
Please note that /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.
The same principles apply to referencing these files as to uploaded 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
… and here is another Bash cell that references the resulting file:
cattest.txt
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 is an example, downloading the three parts of the Stanford Street View House Number dataset—1.5 GB altogether.
Note the cell is locked after downloading, so it will not run again.
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 -sfvextra_32x32.matsvhn/ ln -sfvextra_32x32.matsvhn/ ln -sfvextra_32x32.matsvhn/
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 -vtest.txt/ ls -l test.txt
Modified data files can then be copied into /results
to save and version them.