1
$\begingroup$

cross posted on community.wolfram.com

Title say it all, I want to export _Notebook to cloud as a .nb file and 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 the 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 the 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 a cleaner way, I will move the code to an answer later.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.