Cloud Save

Overview

The cloud storage service helps you manage the binary data storage for your game. You can easily develop multiple cloud save features and scenarios within your game, and include limitations to flexibly control the cost of your infrastructure. With cloud storage, binary objects are stored in slots. Storage limitations control how many slots a user can have in their game. Each slot also has the capability to limit the maximum size of the binary object stored in it.

You can implement different ways for players to increase their storage, including:

  • Offering storage upgrades for purchase
  • Granting players storage upgrades after completing certain actions in-game These slot configurations can apply to either all users in a namespace or to a specific user, allowing you to monetize storage capacity if you choose.

How It Works

To implement the API call using your own game service, please follow the client authorization method. You can also use user credentials to authorize the following actions from your game client directly. For more information, please see AccelByte Cloud Storage Service.

Namespace Slot Configuration

You can use the namespace slot configuration to manage the number of slots available for each user in a namespace (game title). The configuration created will apply to all of the registered users in the specified namespace. Please note that this configuration will only apply to the users who register after the configuration is created. This section only shows create namespace slot example. Please refer to the complete API reference here for other operations.

Creating a Namespace Slot Configuration

Use the admin endpoint to create a namespace slot configuration for each namespaces you are managing. In doing so, you need to have the following permission:

Required permission: resource="ADMIN:NAMESPACE:{namespace}:SLOTCONFIG", action=1 (CREATE)

To create a namespace slot configuration, please follow these steps:

  1. Use the NamespaceConfig: Create a Namespace Slot Configuration - POST /admin/namespaces/config endpoint. Here, you need to fill out these fields in the request body example in order to perform a request:
{
"maxSlotSize": 1000,
"maxSlots": 1000,
"namespace": "accelbyte"
}

Request Body Parameters:

  • maxSlotSize. The maximum size of the binary object data that will be stored in a slot. For example, the maximum slot size is 100MB.
  • maxSlots. The maximum number of slots for each user in a namespace. For example there will be 1000 slots in a namespace.
  • Namespace. The namespace where you want to create a cloud storage.
  1. After a successful request, you will be able to create a namespace slot configuration.

User Slot Configuration

You can also allocate slot limit for a specific user. This functionality can be used for specific cases such as: user purchases storage upgrades, user granted storage upgrades after completing actions in the game, etc. This section only shows create user slot configuration example. Please refer to the complete API reference here for other operations.

Creating Slot Configuration for a Specific User

Using admin endpoint, you can create a slot configuration for user. Each of the users that you are managing can have a different slot which can be updated easily using their userId. In doing so, you need to have the following permission:

Required permission: resource="ADMIN:NAMESPACE:{namespace}:USER:{userId}:SLOTCONFIG", action=1 (CREATE)

To create a slot configuration for user, please follow these steps: 1. Use the SlotConfig: Create a Slot Configuration for User - POST /admin/namespaces/{namespace}/users/{userId}/config endpoint. Here, you need to fill out these fields in order to make a request:

Path Parameters:

  • Namespace. Input the namespace where the user that you want to create a slot belongs to.
  • UserId. Input the user ID of the user you want to create the slot.

Request Body Example:

{
"maxSlotSize": 100,
"maxSlots": 1000,
"namespace": "string",
"userId": "string"
}

Request Body Parameters:

  • maxSlotSize. Input the maximum size of the binary object data that will be stored in a slot. For example, the maximum slot size is 100MB.
  • maxSlots. Input the maximum number of slots stored for the user. For example the user will have 1000 slots available.
  • Namespace. The namespace where the user belongs.
  • UserId. The user ID of the user that the slot will be created.
  1. After a successful request, you will be able to create a slot configuration for a user.

Using Cloud Storage Service from SDK

As a player, you can use some of Cloud Storage function from SDK, such as: create slot, get slot, update slot and delete slot.

Uploading Files from the SDK

For uploading files using cloud storage service, you can either make a new slot for that file or use the existing slot and overwrite it. For more information, please see the example below.

Creating Slot

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
byte[] yourFile;
string yourFileName;
Result<Slot> createSlotResult = null;
cloudStorage.CreateSlot(
yourFile,
yourFileName,
result => { createSlotResult = result; }
);

Updating Slot

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
string existingSlotId;
byte[] yourNewFile;
string yourNewFileName;
Result<Slot> updateSlotResult = null;
cloudStorage.UpdateSlot(
existingSlotId,
yourNewFile,
yourNewFileName,
result => { updateSlotResult = result; }
);

Retrieving Files from Existing Slots from the SDK

After you upload files to some slots, then you can retrieve the files anytime you want. You can retrieve the file by it’s slotId, or just retrieve all slots you have. For more information, please see the example below.

Getting All Slots

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
Result<Slot[]> getAllSlotsResults = null;
cloudStorage.GetAllSlots(
result => { getAllSlotsResults = result; }
);

Getting a Slot

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
string yourSlotId;
Result<byte[]> getSlotResult = null;
cloudStorage.GetSlot(
yourSlotId,
result => { getSlotResult = result; }
);

Deleting Files from the SDK

After you can create and retrieve your file, you can also delete it. For more information, please see the example below.

Deleting Slot

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
string yourSlotId;
Result deleteSlotResult = null;
cloudStorage.DeleteSlot(
yourSlotId,
result => { deleteSlotResult = result; }
);

Updating Files Metadata from the SDK

You can also update your file’s metadata. For more information, please see the example below.

Updating Slot Metadata

CloudStorage cloudStorage = AccelBytePlugin.GetCloudStorage();
string[] tags = {"newTag1", "newTag2"};
string label = "updatedLabel";
string customMeta = "updatedCustom";
string yourSlotId;
Result<Slot> updateSlotMetadataResult = null;
cloudStorage.UpdateSlotMetadata(
yourSlotId,
tags,
label,
customMeta,
result => { updateSlotMetadataResult = result; }
);

What’s Next?

  • You can configure your cloud storage slots by using these API operations.