Maybe ResourceData
is the function you're looking for?
If all you want to do is store an expression in the cloud (e.g. coming from your local data sources) and get it back later (e.g. in a cloud notebook), CloudPut
and CloudGet
might be all you need. There's nothing wrong with ResourceObject
, it just seems a little more "heavy-weight" for this use case.
Both approaches would store the data as a separate cloud object. If you want to access the data from different places, that's probably what you want, anyway. But if you want to make data truly part of a notebook, you'll need something else...
A convenient way to do this (fairly new and still marked as experimental) is PersistentValue
. For instances, you can say
PersistentValue["myvalue", "Notebook"] = 100!;
Dynamic[PersistentValue["myvalue", "Notebook"]]
and it will use data persisted in the notebook itself. When you copy the notebook to the cloud (using CopyFile
, CloudDeploy
or CloudPublish
etc.), the value will still be there. Under the hood, the "Notebook" persistence location just uses a notebook option "NotebookPersistence"
to store the notebook in the notebook. Before PersistentValue
existed, people sometimes did something similar with the notebook option TaggingRules
.
Another way to persist data in a notebook, that I should point out here, is the Initialization
option (of DynamicModule
, Manipulate
and similar constructs). It's a more imperative way of managing your data dependencies (essentially saying "when this interface appears, make sure to evaluate X"). SaveDefinitions
/ IncludeDefinitions
use it under the hood to pull in dependencies, which happens by default in CloudDeploy
and CloudPublish
. So if your Manipulate
depends on pure data that is already in your local kernel, it might "just work" by default when deployed to that cloud using these functions. (But if the function inside your Manipulate
loads data from some external resource on the fly, e.g. by connecting to a database or reading a file, that's when you need more fine-grained control using the mechanisms I described here.)
Hope this helps. Let me know if you have more questions or run into any issues.