Is there an API (say, HTTP POST) to upload an attachment to a notebook outside of observable?
I want to generate a JSON file on my server and upload it to a notebook automatically.
1 Like
Not currently, no. But I want this so much!! One use case is programmatically writing to a file attachment on some user-triggered event inside a notebook, so you can analyze some data or change some state and then save it for everyone. Another use case (maybe more what youāre talking about) is more like cron jobs for ETL-ish stuff. (Iād love to be able to write those in notebooks too, hah, which might require notebooks to run headless on a server somehow.)
Thereās some discussion of this in our Feedback repo; Iād love if you added any needs or details or ideas:
opened 06:17PM - 10 Aug 21 UTC
Feature Request
**Is your feature request related to a problem? Please describe.**
If I am the ā¦ owner of a notebook, I would like to be able via an Observable API to programmatically attach files to that notebook.
Scenarios:
1) I have a visualization instance that I want to keep - I press some link or button and that canvas snapshot is "saved" then attached to the Notebook as a file. ( Right now I would have to manually download the image, then manually upload it to the notebook )
2) I have updated some CSV data via a Notebook interface. I want to update the attached CSV with this information. (Right now I would have to download the attached CSV, update it manually with the new text, delete the existing file attachment, and re-upload the attachment )
3) I have run some analysis on some data in the notebook. I want others who see this notebook to see the results of the analysis. ( Right now I have to download the content, zip it up, then re-attach to the notebook potentially )
**Describe the solution you'd like**
CRUD actions on FileAttachments via a JS api. They would still follow the same file size restrictions as normal file attachments, size amt, etc. Bonus points for being able to update a file inside an attached ZIP archive.
Again - this api would only work for the owner of the Notebook. It would simply be a convenience api around creating, updating, reading, and deleting FileAttachments.
**Describe alternatives you've considered**
Current alternatives are the manual creation / delete / upload via mouse clicks.
Use of LocalStorage works only for the current viewer of the notebook.
**Additional context**
Having a virtualized file system api would lead to some fantastic uses for Observable Notebooks with only a small addition to it's functionality.
2 Likes
(Of course thereās also the option that, if you can store the JSON on the server too, the notebook could fetch it from there.)
1 Like