I’d like to build a URL towards a plain file contents; typically, I’d like my students to be able to click this link so as to download, say, a csv datafile, or an image or a css style sheet, as is (so they can later on use it on their own computer)
in the simplest setup, running Jupyter locally, I have a local folder with notebooks and media files;
http://localhost:8888/files/the-path-to/foo.csv but am ending on a page that reads
where the console says
Uncaught DOMException: Failed to read the 'sessionStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag.
I suspect this has to do with my still using classic notebook; I also have the JupyterLab endpoints enabled so I tried to poke inside the
/lab/ namespace as well, but to no luck so far
I’d appreciate any hint or clue as to how I should try and work around this dead end
my version mix is as follows
Selected Jupyter core packages...
IPython : 8.4.0
ipykernel : 6.15.1
ipywidgets : 7.7.1
jupyter_client : 7.3.4
jupyter_core : 4.11.1
jupyter_server : 1.18.1
jupyterlab : not installed
nbclient : 0.5.13
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : 5.3.1
traitlets : 5.3.0
/files/ should be the correct URL prefix, unless you have additional prefixes. As it says, you will have to have already been logged in.
Some other things to try:
- Does the in-UI download feature work?
- Can your browser tell you what URL that was?
- Anything interesting happening your server log?
Hiya; thanks for the feedback
I do not have any additional prefix in place
as far as the 403 forbidden that I get when following the
/files/ url: I am not sure that I understand the notion of logging in since this is a locally run jupyter server, that I start with
jupyter notebook, and I do not encounter any login form to browse the notebooks contents for example
your hint about using the download feature is interesting; from the classic notebook dir listing, I can indeed select some files and then click ‘Download’, and that works ! however this goes through some JS code (which at least iterates over the selected checkboxes) and so the URL used for that is not exactly obvious to figure…
out of curiosity I tried the same kind of introspection from the jlab interface; the download works from there too, but again it’s not quite obvious to figure the URL used by the JS layer
the server logs just say this when I get the 403 forbidden
[W 17:23:55.143 NotebookApp] 403 GET /files/notebooks/rise.css (::1): Blocking request from unknown origin
[W 17:23:55.158 NotebookApp] 403 GET /files/notebooks/rise.css (::1) 16.180000ms referer=None
PS. my gut feeling is that the JS code has the right settings wrt the same-origin thingy that I find so confusing these days…
see e.g. the
mode: 'cors', // no-cors, *cors, same-origin
parameter to JS’s
fetch function as mentioned in
but then maybe not …