I've got some stuff that I want to be able distribute to my totally real friends, but I don't want to have to email them every time I change something.
How can I set up sharing via the cloud?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityWhen you put stuff in the cloud it's good to use your short URL in the URI (or copy it in after to shrink down the link length and scariness):
CloudPut[1, "user:b3m2a1/whee"]
CloudObject["https://www.wolframcloud.com/objects/b3m2a1/whee"]
The cloud happily makes this really easy. Say we just want to distribute some expression to someone. All we need is the following:
In[307]:= CloudExport[
BinarySerialize["hello!"],
"Package",
Permissions -> "Public"
]
Out[307]= \
CloudObject["https://www.wolframcloud.com/objects/5e6e9b45-1018-46c5-\
bd87-17693d883732"]
And then our friend can go to that link and the thing will download for them to work with. Or, better yet, they can import it directly into Mathematica:
In[308]:= CloudImport@CloudObject[
"https://www.wolframcloud.com/objects/5e6e9b45-1018-46c5-bd87-\
17693d883732"]
Out[308]= ByteArray[< 10 >]
For that they, too, will need a free cloud account, but if they don't want to do that all is not lost. The resource is still semi-accessible via Import
:
In[312]:= Import[CloudObject[
"https://www.wolframcloud.com/objects/5e6e9b45-1018-46c5-bd87-\
17693d883732"],
"Text"
]
Out[312]= "(* Created with the Wolfram Language : www.wolfram.com *)
\
ByteArray[\"NzpTBmhlbGxvIQ==\"]"
And a quick little ToExpression
will extract what we need.
Note that this won't alway work absolutely as formatting can get wonky.
Furthermore, if we use a fixed URL:
In[319]:= CloudExport[
BinarySerialize["hello!"],
"Package",
"hello-array",
Permissions -> "Public"
]
Out[319]= \
CloudObject["https://www.wolframcloud.com/objects/user-affd7b1c-ecb6-\
4ccc-8cc4-4d107e2bf04a/hello-array"]
our friend need only know one URL and the updating version will always be available
Where this really gets cool, though, is how you can distribute packages.
The CloudGet
function acts just like Get
but for the cloud, and so if you have a package file and you copy it to the cloud via CopyFile
, your friend can run CloudGet
on that and all of your code will become immediately accessible to them.
But wait! There's more!
We can set up a paclet site in the cloud so that our entire application can be easily distributed. And we can combine this with CloudGet
to configure an auto-installer for our package. Run this:
CloudGet@"https://wolfr.am/l514yL7C"
and (assuming I haven't broken anything since I last tested it) you'll get the current version of a package of little tools I wrote. Note that I used URLShorten
on the longer URL that that hides.
You can then uninstall this via:
CloudGet@"https://wolfr.am/l51cHPOm"
Note, too, that the cloud can take standard HTML/CSS content, too.
I have code that will turn a PacletSite.mz into an HTML page that can be deployed.
So going above and beyond what I'd done before with the cloud I recently wrote a system to push a full static website up there: https://www.wolframcloud.com/objects/b3m2a1/home/building-websites-with-mathematica.html#main-content
The www.wolframcloud.com/objects is ugly, yes, but it's so convenient to just be able to push things from within Mathematica (as I write my posts and pages in Mathematica anyway).
BinarySerialize
in your example?
$\endgroup$
Apr 21, 2017 at 8:57