Provides access to Cloud Storage.

// 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);
}
interface CloudStorageModule {
    name: string;
    uniqueIdentifier: string;
    getCloudStore(options: CloudStorageOptions, onCloudStoreReady: ((store: CloudStore) => void), onError: ((code: string, description: string) => void)): void;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

name: string

The name of the Asset in Lens Studio.

uniqueIdentifier: string

Methods

  • Get the Cloud Store. Future calls to this method will return the same cloud store, even if the options change.

    Parameters

    • options: CloudStorageOptions
    • onCloudStoreReady: ((store: CloudStore) => void)
        • (store): void
        • Parameters

          Returns void

    • onError: ((code: string, description: string) => void)
        • (code, description): void
        • Parameters

          • code: string
          • description: string

          Returns void

    Returns void

  • Returns the name of this object's type.

    Returns string

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean