Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compress the contents of a cloud object that contains a Wolfram Language expression
| ResourceFunction["CompressCloudObject"][obj] compresses the contents of the CloudObject obj. | |
| ResourceFunction["CompressCloudObject"][obj,target] compresses a copy of obj at target. | 
Compress the contents of a CloudObject:
| In[1]:= | ![(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/a8627186-3f14-4452-b6b2-d37a803648da"]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/424dbb29894da57d.png) | 
| Out[3]= |  | 
| In[4]:= | ![ResourceFunction["CompressCloudObject"][CloudObject["temp"]]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/0b92f848b8ab8c7d.png) | 
| Out[4]= |  | 
The size of the CloudObject is reduced:
| In[5]:= | ![FileByteCount[CloudObject["temp"]]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/3f1201392f6bab86.png) | 
| Out[5]= |  | 
The content is preserved:
| In[6]:= | ![CloudGet["temp"]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/3250b666e92fcf52.png) | 
| Out[6]= |  | 
| In[7]:= |  | 
| Out[7]= |  | 
Specify a target location:
| In[8]:= | ![original = CloudPut[RandomInteger[100, 10000]]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/06daed73a6eed323.png) | 
| Out[8]= |  | 
| In[9]:= | ![new = ResourceFunction["CompressCloudObject"][original, CloudObject[]]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/241cecc4e127b683.png) | 
| Out[9]= |  | 
The original file remains unchanged:
| In[10]:= | ![CloudGet[original] === CloudGet[new]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/6ccf4a67a6958910.png) | 
| Out[10]= |  | 
The new file is much smaller:
| In[11]:= | ![FileByteCount[new]/FileByteCount[original] // N](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/3925f29daf6d9d49.png) | 
| Out[11]= |  | 
The content of the compressed CloudObject is an unevaluated Uncompress expression:
| In[12]:= | ![obj = CloudPut[ConstantArray[0, 1000]];
ResourceFunction["CompressCloudObject"][obj]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/462044ceb2fc8a88.png) | 
| Out[13]= |  | 
| In[14]:= | ![ToExpression[CloudImport[obj, "Text"], InputForm, Hold]](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/2d5268c3f8126180.png) | 
| Out[14]= |  | 
| In[15]:= | ![ReleaseHold[%] // Short](https://www.wolframcloud.com/obj/resourcesystem/images/1a0/1a06012a-51c2-4a7c-ade5-b517a0dabc89/04aaae93d30b218a.png) | 
| Out[15]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License