Message Boards Message Boards

Best practices for uploading notebooks and creating download hyperlinks?

GROUPS:

cross posted on mathematica.stackexchange.com

I want to export _Notebook to the 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 solution. 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" or CloudDeploy 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 expect Hyperlink 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.

Is there a better way or is it a way to go?

POSTED BY: Kuba Podkalicki
Answer
12 days ago

Group Abstract Group Abstract