ゲーム全体のデータをバイナリレコードに保存する
注釈:本資料はAI技術を用いて翻訳されています。
概要
AccelByte Gaming Services (AGS) のCloud Saveサービスを使用すると、ゲームデータをバイナリ形式で保存できます。保存されるデータは、プレイヤーがアクセスでき、場合によっては編集可能なグローバルタイトル用です。
この記事では、バイナリレコードを使用してプレイヤーデータを保存、取得、およびゲームのユースケースに応じて変更する方法を学びます。
目標
この記事では、ゲームバイナリレコードの概要と AGS Game SDK での使用方法を説明し、以下の操作方法を示します。
- ゲームデータをバイナリレコードに保存する
- ゲームバイナリレコードを取得する
- ゲームバイナリレコードを変更する
- ゲームバイナリレコードを削除する
前提条件
この記事の手順を完了するには、以下が必要です。
- AGS Admin Portal へのアクセス
- 必要な権限を持つ Unreal または Unity 用の AGS Game SDK がゲームプロジェクトにインストールされていること
- Client ID
- Client Secret
ゲームサーバーでゲームデータをバイナリレコードに保存する
ゲームデータをバイナリレコードに保存できるのはゲームサーバーのみです。このセクションの手順を完了することで設定できます。
ゲームバイナリレコードリクエストを作成する
まず、保存したいバイナリレコードを作成する必要があります。このプロセスから、後でバイナリファイルをアップロードするために使用される生成済みの事前署名URLを取得します。次の関数を使用してリクエストを作成できます。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
EAccelByteFileType FileType = EAccelByteFileType::BIN; // Valid file types are jpeg, jpg, png, bmp, gif, mp3, webp, and bin
ESetByMetadataRecord SetBy = ESetByMetadataRecord::CLIENT; // Set to client if you want the binary to be managed by the game client or using public endpoints
ServerApiClient->ServerBinaryCloudSave.CreateGameBinaryRecord(Key
, FileType
, SetBy
, THandler<FAccelByteModelsBinaryInfo>::CreateLambda([](FAccelByteModelsBinaryInfo Result)
{
// Do something if CreateGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if CreateGameBinaryRecord fails
}));
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
FileType fileType = FileType.BIN;
RecordSetBy setBy = RecordSetBy.CLIENT;
serverBinaryCloudSave.CreateGameBinaryRecord(key, fileType, setBy, ttlConfig: null, result =>
{
if (result.IsError)
{
// Your logic to handle errors in CreateGameBinaryRecord
// ...
Debug.Log($"Error CreateGameBinaryRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after CreateGameBinaryRecord succeeds
});
var response = sdk.Cloudsave.AdminGameBinaryRecord.AdminPostGameBinaryRecordV1Op
.Execute(new ModelsGameBinaryRecordCreate()
{
FileType = "bin",
SetBy = ModelsGameBinaryRecordCreateSetBy.CLIENT
}, sdk.Namespace);
if (response != null)
{
string presignedUrlToUpload = response.Url!;
}
adminGameBinaryRecordService := &cloudsave.AdminGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
fileType := "bin"
setBy := "SERVER"
body := &cloudsaveclientmodels.ModelsGameBinaryRecordCreate {
FileType: &fileType,
SetBy: &setBy,
}
namespace := "mygame"
input := &admin_game_binary_record.AdminPostGameBinaryRecordV1Params{
Body: body,
Namespace: namespace,
}
result, err := adminGameBinaryRecordService.AdminPostGameBinaryRecordV1Short(input)
AdminGameBinaryRecord adminGameBinaryRecordWrapper = new AdminGameBinaryRecord(sdk);
ModelsUploadBinaryRecordResponse response;
try {
ModelsGameBinaryRecordCreate reqBody = ModelsGameBinaryRecordCreate.builder()
.fileType("bin")
.setBy(ModelsGameBinaryRecordCreate.SetBy.CLIENT.toString())
.build();
response = adminGameBinaryRecordWrapper.adminPostGameBinaryRecordV1(AdminPostGameBinaryRecordV1.builder()
.namespace("<namespace>")
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
String presignedUrlToUpload = response.getUrl();
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_post_game_binary_record_v1(
body=cloudsave_models.ModelsGameBinaryRecordCreate()
.with_key("GameInformation1")
.with_set_by("CLIENT")
.with_file_type("bin"),
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
または一時的なゲームバイナリレコードリクエストを作成する
- Unreal
- Unity
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
EAccelByteFileType FileType = EAccelByteFileType::BIN; // Valid file types are jpeg, jpg, png, bmp, gif, mp3, webp, and bin
ESetByMetadataRecord SetBy = ESetByMetadataRecord::CLIENT; // Set to client if you want the binary to be managed by the game client or using public endpoints
FTTLConfig TTLConfig{};
TTLConfig.Action = EAccelByteTTLConfigAction::DELETE_RECORD;
TTLConfig.Expires_At = FDateTime::UtcNow() + FTimespan(0, 0, 5); // Will delete this record in the next five seconds
ServerApiClient->ServerBinaryCloudSave.CreateGameBinaryRecord(Key
, FileType
, SetBy
, THandler<FAccelByteModelsBinaryInfo>::CreateLambda([](FAccelByteModelsBinaryInfo Result)
{
// Do something if CreateGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if CreateGameBinaryRecord fails
})
, TTLConfig);
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
FileType fileType = FileType.BIN;
RecordSetBy setBy = RecordSetBy.CLIENT;
var ttlConfig = new TTLConfig()
{
Action = TTLConfigAction.Delete,
ExpiresAt = DateTime.Now.AddSeconds(5) // Will delete this record in the next five sceonds
};
serverBinaryCloudSave.CreateGameBinaryRecord(key, fileType, setBy, ttlConfig, result =>
{
if (result.IsError)
{
// Your logic to handle errors in CreateGameBinaryRecord
// ...
Debug.Log($"Error CreateGameBinaryRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after CreateGameBinaryRecord succeeds
});
バイナリファイルをアップロードする
取得した事前署名URLを使用してバイナリファイルを直接アップロードします。次の関数を使用してバイナリファイルをアップロードできます。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PresignedUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35 };
FAccelByteNetUtilities::UploadTo(Url
, DataUpload
, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
})
, FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));
string url = "PresignedUrlToUpload";
byte[] dataUpload = new byte[] { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35 }
AccelByteNetUtilities.UploadBinaryTo(url, dataUpload, result =>
{
if (result.IsError)
{
// Your logic to handle errors in UploadBinaryTo
// ...
Debug.Log(result.Error.Message);
return;
}
// Your logic to run after UploadBinaryTo succeeds
});
string presignedUrlToUpload = "<url>"; // From AdminPostGameBinaryRecordV1
byte[] dataToUpload = new byte[] { 10, 30, 40, 50, 60, 70, 80 };
var isSuccess = sdk.UploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
presignedURL := "PresignedUrlToUpload"
filePath := "FilePath"
resp, err := utils.UploadBinaryFile(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>"; // From AdminPostGameBinaryRecordV1
byte[] dataToUpload = new byte[] { 10, 30, 40, 50, 60, 70, 80 };
final boolean isSuccess = sdk.uploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
from accelbyte_py_sdk.core import get_http_client
# data_upload = ...
url = "PresignedUrlToUpload"
response = get_http_client().upload_binary_data(
url=url,
data=data_upload,
headers={
"Content-Type": "application/octet-stream",
}
)
コミットしてファイルの場所を更新する
バイナリファイルがアップロードされたら、変更をコミットして新しいファイルの場所が更新されるようにします。次の関数を使用します。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
EAccelByteFileType FileType = EAccelByteFileType::BIN; // Valid file types are jpeg, jpg, png, bmp, gif, mp3, webp, and bin
FString FileLocation = "PresignUrlFileLocation";
ServerApiClient->ServerBinaryCloudSave.UpdateGameBinaryRecord(Key
, FileType
, FileLocation
, THandler<FAccelByteModelsGameBinaryRecord>::CreateLambda([](FAccelByteModelsGameBinaryRecord Result)
{
// What to do if UpdateGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if UpdateGameBinaryRecord fails
}));
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
FileType fileType = FileType.BIN;
string fileLocation = "PresignUrlFileLocation";
serverBinaryCloudSave.UpdateGameBinaryRecord(key, fileType, fileLocation, result =>
{
if (result.IsError)
{
// Your logic to handle errors in UpdateGameBinaryRecord
// ...
Debug.Log(result.Error.Message);
return;
}
// Your logic to run after UpdateGameBinaryRecord succeeds
})
string key = "someKey";
string presignedUrlToUpload = "<url>";
var response = sdk.Cloudsave.AdminGameBinaryRecord.AdminPutGameBinaryRecordV1Op
.Execute(new ModelsBinaryRecordRequest()
{
ContentType = "application/octet-stream",
FileLocation = presignedUrlToUpload
}, key, sdk.Namespace);
if (response != null)
{
// Do something if successful
}
adminGameBinaryRecordService := &cloudsave.AdminGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
contentType := "application/octet-stream"
fileLocation := "presignedUrlToUpload"
body := &cloudsaveclientmodels.ModelsBinaryRecordRequest {
ContentType: &contentType,
FileLocation: &fileLocation,
}
key := "someKey"
namespace := "mygame"
input := &admin_game_binary_record.AdminPutGameBinaryRecordV1Params{
Body: body,
Key: key,
Namespace: namespace,
}
result, err := adminGameBinaryRecordService.AdminPutGameBinaryRecordV1Short(input)
AdminGameBinaryRecord adminGameBinaryRecordWrapper = new AdminGameBinaryRecord(sdk);
String key = "someKey";
String presignedUrlToUpload = "<url>";
ModelsGameBinaryRecordAdminResponse response;
try {
ModelsBinaryRecordRequest reqBody = ModelsBinaryRecordRequest.builder()
.contentType("application/octet-stream")
.fileLocation(presignedUrlToUpload)
.build();
response = adminGameBinaryRecordWrapper.adminPutGameBinaryRecordV1(AdminPutGameBinaryRecordV1.builder()
.namespace("<namespace>")
.key(key)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_put_game_binary_record_v1(
body=cloudsave_models.ModelsBinaryRecordRequest()
.with_content_type("bin")
.with_file_location("PresignUrlFileLocation"),
key="GameInformation1",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
ゲームサーバーからゲームバイナリレコードファイルを更新する
ゲームバイナリレコードに新しいバイナリファイルをアップロードする手順は、ゲームバイナリレコードの作成とは若干異なります。ゲームクライアントから新しいバイナリファイルをアップロードするには、このセクションの手順を完了してください。
事前署名URLをリクエストする
まず、更新されたバイナリファイルをアップロードするために使用する事前署名URLをリクエストする必要があります。次の関数を使用してリクエストできます。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
EAccelByteFileType FileType = EAccelByteFileType::BIN; // Valid file types are jpeg, jpg, png, bmp, gif, mp3, webp, and bin
ServerApiClient->ServerBinaryCloudSave.RequestGameBinaryRecordPresignedUrl(Key
, FileType
, THandler<FAccelByteModelsBinaryInfo>::CreateLambda([](FAccelByteModelsBinaryInfo Result)
{
// What to do if RequestGameBinaryRecordPresignedUrl succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if RequestGameBinaryRecordPresignedUrl fails
}));
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
FileType fileType = FileType.BIN;
serverBinaryCloudSave.RequestGameBinaryRecordPresignedUrl(key, fileType, result =>
{
if (result.IsError)
{
// Your logic to handle errors in RequestGameBinaryRecordPresignedUrl
// ...
Debug.Log($"Error RequestGameBinaryRecordPresignedUrl, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after RequestGameBinaryRecordPresignedUrl succeeds
});
string key = "someKey";
var response = sdk.Cloudsave.AdminGameBinaryRecord.AdminPostGameBinaryPresignedURLV1Op
.Execute(new ModelsUploadBinaryRecordRequest()
{
FileType = "bin"
}, key, sdk.Namespace);
if (response != null)
{
string presignedUrlToUpload = response.Url!;
}
adminGameBinaryRecordService := &cloudsave.AdminGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
fileType := "bin"
body := &cloudsaveclientmodels.ModelsUploadBinaryRecordRequest {
FileType: &fileType,
}
key := "someKey"
namespace := "mygame"
input := &admin_game_binary_record.AdminPostGameBinaryPresignedURLV1Params{
Body: body,
Key: key,
Namespace: namespace,
}
result, err := adminGameBinaryRecordService.AdminPostGameBinaryPresignedURLV1Short(input)
AdminGameBinaryRecord adminGameBinaryRecordWrapper = new AdminGameBinaryRecord(sdk);
String key = "someKey";
ModelsUploadBinaryRecordResponse response;
try {
ModelsUploadBinaryRecordRequest reqBody = ModelsUploadBinaryRecordRequest.builder()
.fileType("bin")
.build();
response = adminGameBinaryRecordWrapper.adminPostGameBinaryPresignedURLV1(AdminPostGameBinaryPresignedURLV1.builder()
.namespace("<namespace>")
.key(key)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
String presignedUrlToUpload = response.getUrl();
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_post_game_binary_presigned_urlv1(
body=cloudsave_models.ModelsUploadBinaryRecordRequest()
.with_file_type("bin"),
key="GameInformation1",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
新しいバイナリファイルをアップロードする
取得した事前署名URLを使用してバイナリファイルを直接アップロードします。次の関数を使用してバイナリファイルをアップロードできます。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PresignedUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35 };
FAccelByteNetUtilities::UploadTo(Url
, DataUpload
, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
})
, FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));
string url = "PresignedUrlToUpload";
byte[] dataUpload = new byte[] { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35 }
AccelByteNetUtilities.UploadBinaryTo(url, dataUpload, result =>
{
if (result.IsError)
{
// Your logic to handle errors in UploadBinaryTo
// ...
Debug.Log(result.Error.Message);
return;
}
// Your logic to run after UploadBinaryTo succeeds
});
string presignedUrlToUpload = "<url>"; // From AdminPostGameBinaryPresignedURLV1Op
byte[] dataToUpload = new byte[] { 80, 30, 40, 50, 60, 70, 80 };
var isSuccess = sdk.UploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
presignedURL := "PresignedUrlToUpload"
filePath := "FilePath"
resp, err := utils.UploadBinaryFile(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>"; // From AdminPostGameBinaryPresignedURLV1
byte[] dataToUpload = new byte[] { 80, 30, 40, 50, 60, 70, 80 };
final boolean isSuccess = sdk.uploadBinaryData(presignedUrlToUpload, dataToUpload, "application/octet-stream");
if (isSuccess)
{
// Do something if upload succeeds
}
from accelbyte_py_sdk.core import get_http_client
# data_upload = ...
url = "PresignedUrlToUpload"
response = get_http_client().upload_binary_data(
url=url,
data=data_upload,
headers={
"Content-Type": "application/octet-stream",
}
)
再度コミットしてファイルの場所を更新する
バイナリファイルがアップロードされたら、変更をコミットして新しいファイルの場所が更新されるようにします。次の関数を使用します。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
EAccelByteFileType FileType = EAccelByteFileType::BIN; // Valid file types are jpeg, jpg, png, bmp, gif, mp3, webp, and bin
FString FileLocation = "PresignUrlFileLocation";
ServerApiClient->ServerBinaryCloudSave.UpdateGameBinaryRecord(Key
, FileType
, FileLocation
, THandler<FAccelByteModelsGameBinaryRecord>::CreateLambda([](FAccelByteModelsGameBinaryRecord Result)
{
// What to do if UpdateGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if UpdateGameBinaryRecord fails
}));
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
FileType fileType = FileType.BIN;
string fileLocation = "PresignUrlFileLocation";
serverBinaryCloudSave.UpdateGameBinaryRecord(key, fileType, fileLocation, result =>
{
if (result.IsError)
{
// Your logic to handle errors in UpdateGameBinaryRecord
// ...
Debug.Log(result.Error.Message);
return;
}
// Your logic to run after UpdateGameBinaryRecord succeeds
})
string key = "someKey";
string presignedUrlToUpload = "<url>";
var response = sdk.Cloudsave.AdminGameBinaryRecord.AdminPutGameBinaryRecordV1Op
.Execute(new ModelsBinaryRecordRequest()
{
ContentType = "application/octet-stream",
FileLocation = presignedUrlToUpload
}, key, sdk.Namespace);
if (response != null)
{
// Do something if successful
}
adminGameBinaryRecordService := &cloudsave.AdminGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
contentType := "application/octet-stream"
fileLocation := "presignedUrlToUpload"
body := &cloudsaveclientmodels.ModelsBinaryRecordRequest {
ContentType: &contentType,
FileLocation: &fileLocation,
}
key := "someKey"
namespace := "mygame"
input := &admin_game_binary_record.AdminPutGameBinaryRecordV1Params{
Body: body,
Key: key,
Namespace: namespace,
}
result, err := adminGameBinaryRecordService.AdminPutGameBinaryRecordV1Short(input)
AdminGameBinaryRecord adminGameBinaryRecordWrapper = new AdminGameBinaryRecord(sdk);
String key = "someKey";
String presignedUrlToUpload = "<url>";
ModelsGameBinaryRecordAdminResponse response;
try {
ModelsBinaryRecordRequest reqBody = ModelsBinaryRecordRequest.builder()
.contentType("application/octet-stream")
.fileLocation(presignedUrlToUpload)
.build();
response = adminGameBinaryRecordWrapper.adminPutGameBinaryRecordV1(AdminPutGameBinaryRecordV1.builder()
.namespace("<namespace>")
.key(key)
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_put_game_binary_record_v1(
body=cloudsave_models.ModelsBinaryRecordRequest()
.with_content_type("bin")
.with_file_location("PresignUrlFileLocation"),
key="GameInformation1",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
ゲームサーバーからゲームバイナリレコードを削除する
次の関数を使用してゲームバイナリレコードを削除します。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FServerApiClientPtr ServerApiClient = AccelByteOnlineSubsystemPtr->GetServerApiClient();
FString Key = "GameInformation1";
ServerApiClient->ServerBinaryCloudSave.DeleteGameBinaryRecord(Key
, FVoidHandler::CreateLambda([]()
{
// What to do if DeleteGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if DeleteGameBinaryRecord fails
}));
ServerBinaryCloudSave serverBinaryCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
serverBinaryCloudSave.DeleteGameBinaryRecord(key, result =>
{
if (result.IsError)
{
// Your logic to handle errors in DeleteGameBinaryRecord
// ...
Debug.Log($"Error DeleteGameBinaryRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after DeleteGameBinaryRecord succeeds
});
string key = "someKey";
sdk.Cloudsave.AdminGameBinaryRecord.AdminDeleteGameBinaryRecordV1Op
.Execute(key, sdk.Namespace);
adminGameBinaryRecordService := &cloudsave.AdminGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "someKey"
namespace := "mygame"
input := &admin_game_binary_record.AdminDeleteGameBinaryRecordV1Params{
Key: key,
Namespace: namespace,
}
err := adminGameBinaryRecordService.AdminDeleteGameBinaryRecordV1Short(input)
final AdminGameBinaryRecord adminGameBinaryRecordWrapper = new AdminGameBinaryRecord(sdk);
String key = "someKey";
try {
adminGameBinaryRecordWrapper.adminDeleteGameBinaryRecordV1(AdminDeleteGameBinaryRecordV1.builder()
.namespace("<namespace>")
.key(key)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_delete_game_binary_record_v1(
key="GameInformation1",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
ゲームクライアントからゲームバイナリレコードデータを取得する
ゲームバイナリレコードデータが保存された後、プレイヤーがそのデータを取得できるようにすることができます。
単一のレコードを取得する
次の関数を使用して、キーで特定のゲームバイナリレコードデータを取得します。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
FString Key = "GameInformation1";
ApiClient->BinaryCloudSave.GetGameBinaryRecord(Key
, THandler<FAccelByteModelsGameBinaryRecord>::CreateLambda([](FAccelByteModelsGameBinaryRecord Result)
{
// What to do if GetGameBinaryRecord succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if GetGameBinaryRecord fails
}));
BinaryCloudSave binaryCloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetBinaryCloudSave();
string key = "GameInformation1";
binaryCloudSave.GetGameBinaryRecord(key, result =>
{
if (result.IsError)
{
// Your logic to handle errors in GetGameBinaryRecord
// ...
Debug.Log($"Error GetGameBinaryRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after GetGameBinaryRecord succeeds
});
string key = "someKey";
var response = sdk.Cloudsave.PublicGameBinaryRecord.GetGameBinaryRecordV1Op
.Execute(key, sdk.Namespace);
if (response != null)
{
// Do something if successful
}
publicGameBinaryRecordService := &cloudsave.PublicGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "somekey"
namespace := "mygame"
input := &public_game_binary_record.GetGameBinaryRecordV1Params{
Key: key,
Namespace: namespace,
}
result, err := publicGameBinaryRecordService.GetGameBinaryRecordV1Short(input)
PublicGameBinaryRecord publicGameBinaryRecordWrapper = new PublicGameBinaryRecord(sdk);
String key = "someKey";
ModelsGameBinaryRecordResponse response;
try {
response = publicGameBinaryRecordWrapper.getGameBinaryRecordV1(GetGameBinaryRecordV1.builder()
.namespace("<namespace>")
.key(key)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.get_game_binary_record_v1(
key="GameInformation1",
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
複数のレコードを取得する
次の関数を使用して、ゲームバイナリレコードのリストを取得します。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FApiClientPtr ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient();
TArray<FString> Keys = { "GameInformation1", "GameInformation2" };
ApiClient->BinaryCloudSave.BulkGetGameBinaryRecords(Keys
, THandler<FAccelByteModelsListGameBinaryRecords>::CreateLambda([](FAccelByteModelsListGameBinaryRecords Result)
{
// What to do if BulkGetGameBinaryRecords succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// What to do if BulkGetGameBinaryRecords fails
}));
BinaryCloudSave binaryCloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetBinaryCloudSave();
string[] keys = { "GameInformation1", "GameInformation2" };
binaryCloudSave.BulkGetGameBinaryRecords(keys, result =>
{
if (result.IsError)
{
// Your logic to handle errors in BulkGetGameBinaryRecords
// ...
Debug.Log($"Error BulkGetGameBinaryRecords, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after BulkGetGameBinaryRecords succeeds
});
string[] keys = new[] { "key1", "key2" };
var response = sdk.Cloudsave.PublicGameBinaryRecord.BulkGetGameBinaryRecordV1Op
.Execute(new ModelsBulkGetGameRecordRequest()
{
Keys = new List<string>(keys)
}, sdk.Namespace);
if (response != null)
{
// Do something if successful
}
publicGameBinaryRecordService := &cloudsave.PublicGameBinaryRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
body := &cloudsaveclientmodels.ModelsBulkGetGameRecordRequest {
Keys: string[] {"key1", "key2"},
}
namespace := "mygame"
input := &public_game_binary_record.BulkGetGameBinaryRecordV1Params{
Body: body,
Namespace: namespace,
}
result, err := publicGameBinaryRecordService.BulkGetGameBinaryRecordV1Short(input)
PublicGameBinaryRecord publicGameBinaryRecordWrapper = new PublicGameBinaryRecord(sdk);
List<String> keys = Arrays.asList("key1", "key2");
ModelsBulkGetGameBinaryRecordResponse response;
try {
ModelsBulkGetGameRecordRequest reqBody = ModelsBulkGetGameRecordRequest.builder()
.keys(keys)
.build();
response = publicGameBinaryRecordWrapper.bulkGetGameBinaryRecordV1(BulkGetGameBinaryRecordV1.builder()
.namespace("<namespace>")
.body(reqBody)
.build());
} catch (Exception e) {
// Do something if an error occurs
return;
}
if (response == null) {
// Null response from server
} else {
// Do something if successful
}
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.bulk_get_game_binary_record_v1(
body=ModelsBulkGetGameRecordRequest().with_keys(["GameInformation1", "GameInformation2"]),
namespace=namespace, # optional, gets the value from the global instance if unspecified
sdk=sdk, # optional, gets the global instance if unspecified
)
if error:
exit(error)
バイナリファイルをダウンロードする
取得した事前署名URLを使用してバイナリファイルを直接ダウンロードします。次の関数を使用してバイナリファイルをダウンロードできます。
- Unreal
- Unity
- C# Extend SDK
- Go Extend SDK
- Java Extend SDK
- Python Extend SDK
FString Url = "PresignedUrlToDownload";
FAccelByteNetUtilities::DownloadFrom(Url
, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if DownloadFrom still in progress successful
})
, THandler<TArray<uint8>>::CreateLambda([&](const TArray<uint8>& RawData)
{
// Do something if DownloadFrom succeeds
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DownloadFrom fails
}));
string url = "PresignedUrlToDownload";
AccelByteNetUtilities.DownloadBinaryFrom(url, result =>
{
if (result.IsError)
{
// Your logic to handle errors in DownloadBinaryFrom
// ...
Debug.Log($"Error DownloadBinaryFrom, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Your logic to run after DownloadBinaryFrom succeeds
});
string binaryUrl = "<url>";
byte[] downloadedData = sdk.DownloadBinaryData(binaryUrl);
// Do something with the downloaded Data if download succeeds
presignedURL := "PresignedUrlToDownload"
filePath := "FilePath"
resp, err := utils.DownloadBinary(presignedURL, token, filePath)
if err != nil {
// Do something if an error occurs
}
String presignedUrlToUpload = "<url>";
byte[] downloadedData = sdk.downloadBinaryData(presignedUrlToUpload);
// Do something with the downloaded Data if download succeeds
from accelbyte_py_sdk.core import get_http_client
http_client =
response = get_http_client().get(url="PresignedUrlToDownload")