CloudStorageModule
ClassProvides access to Cloud Storage capabilities.
- Available on all platforms
Since Lens Scripting v173
Not available on SPECS. Use Snap Cloud for persistence there instead.
Index
Properties
Methods
Mobile Only
Example
// Check out Persistent Cloud Storage example in the Asset Library
const cloudStorageOptions = CloudStorageOptions.create();
script.cloudStorageModule.getCloudStore(
cloudStorageOptions,
onCloudStoreReady,
onError
);
function onCloudStoreReady(store) {
// Write
const writeOptions = CloudStorageWriteOptions.create();
writeOptions.scope = StorageScope.User;
store.setValue(
"myKey",
"myValue",
writeOptions,
function onSuccess() {
print("Stored Succesfully!");
// List
const listOptions = CloudStorageListOptions.create();
listOptions.scope = StorageScope.User;
store.listValues(
listOptions,
function(results, cursor) {
// Results are returned as a list of [key, value] tuples
for (var i = 0; i < results.length; ++i) {
var key = results[i][0];
var value = results[i][1];
print(' - key: ' + key + ' value: ' + value);
}
},
onError
);
},
onError
);
}
function onError(code, message) {
print('Error: ' + code + ' ' + message);
}
Extends
Properties
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getCloudStore()
getCloudStore(
options,onCloudStoreReady,onError):void
Get the Cloud Store. Future calls to this method will return the same cloud store, even if the options change.
Parameters
| Parameter | Type |
|---|---|
options | CloudStorageOptions |
onCloudStoreReady | (store) => void |
onError | (code, description) => void |
Returns
void
Since
Lens Scripting Version 173
Mobile Only
getTypeName()
staticgetTypeName():TypeName<CloudStorageModule>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<CloudStorageModule>
Since
Lens Scripting Version 173
Mobile Only
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean