When you publish (or share) a notebook, only the files currently used by the notebook will become public.
So, if you use a bunch of files during development, but you’re only using one file when you publish, then only the one file will be made public. The others will remain private. They’re still be visible to you (if you need them), but only files that are actually used by your notebook will be made public on publish. You can verify this by visiting your notebook in incognito mode, and we also show a little lock icon next to private files.
If you replace a file on an already-published notebook and then republish, both files will remain public. But since notebooks can also be imported as components, that’s generally a good thing because it keeps imports of an earlier version working.
It’s on our backlog to make working with file attachments easier. For example, I very much want file attachments to be incorporated into notebook history so that you can replace a file without having to rename it, and everything just works, and you don’t need to accumulate lots of files. I don’t know when we’ll be able to work on this, but we’ll keep you posted when we do.
Thanks for the suggestions @asg017, but ideally I would need a list of the file names…
My use case: an interface where the user can upload some data, select a few parameters (including selecting the file for the data they just uploaded), and output a chart.
Are you referring to notebook authors or notebook visitors? Visitor uploads only live in the browser and are never sent to the server (unless you integrate some third party services).
FileAttachments can only be added by the notebook author, and there is currently no official way to retrieve them dynamically.
However, If the notebook is at least linkshared, you can extract them from the notebook’s module file. Example:
Explaining the use case in more detail: I want the notebook (let’s call it a “Chart Generator”) to be as simple as possible for users without coding experience. Ideally:
They fork the “Chart Generator” template notebook
They attach some csv data
A select box allows them to pick that file they have just attached
With a few more inputs, they select some configs (type: bar chart, color: red, etc.)
The notebook plots a chart
The missing part for me here is step 3, and that’s why I would need an array with the list of file attachments. It would be exactly the output of __NEXT_DATA__.props.pageProps.initialNotebook.files.map(d => d.name) which you pointed out, but accessible within the notebook.