Title say it all, I want to export _Notebook to cloud as a .nb file a make it available to download via hyperlink in different places.
This is rather a code-review question because I have the working code.
The problem is that it does not feel idiomatic:
(*uploading notebook*) co = CloudExport[ ExportString[ Notebook[{Cell[BoxData@ToBoxes@Defer[1 + 1], "Input"]}] , "NB" ] , "Text" , "test/notebook.nb" ]
(*cloud object with a download link*) With[ { hyperlink = StringTemplate[ "<a href = \"``\" download>Download notebook</a>" ] @ First @ co } , CloudDeploy[ Column[{ EmbeddedHTML[hyperlink], Manipulate[x, {x, 0, 1}]}] , "test/fileHyperlink" ] ]
I want to address following issues:
-
Exporting .nb via ExportString + Text.
Straightforward
CloudExport
as “NB” orCloudDeploy
would be better but I can’t restrict it to not being treated as a Cloud Notebook and what is fetched otherwise is an html file. -
Download link
It is nice that
EmbeddCode
almost works but one would expectHyperlink
to do that. I failed to find correct syntax for it e.g.Hyperlink[lbl, File[url]]
redirects to plain text .nb in a browser.
So, unless I missed something and someone provides cleaner way, I will move the code to an answer later.