メインコンテンツまでスキップ

ゲーム全体のデータをバイナリレコードに保存する

Last updated on February 4, 2026

注釈:本資料はAI技術を用いて翻訳されています。

概要

AccelByte Gaming Services (AGS) のCloud Saveサービスを使用すると、ゲームデータをバイナリ形式で保存できます。保存されるデータは、プレイヤーがアクセスでき、場合によっては編集可能なグローバルタイトル用です。

この記事では、バイナリレコードを使用してプレイヤーデータを保存、取得、およびゲームのユースケースに応じて変更する方法を学びます。

目標

この記事では、ゲームバイナリレコードの概要と AGS Game SDK での使用方法を説明し、以下の操作方法を示します。

  • ゲームデータをバイナリレコードに保存する
  • ゲームバイナリレコードを取得する
  • ゲームバイナリレコードを変更する
  • ゲームバイナリレコードを削除する

前提条件

この記事の手順を完了するには、以下が必要です。

  • AGS Admin Portal へのアクセス
  • 必要な権限を持つ Unreal または Unity 用の AGS Game SDK がゲームプロジェクトにインストールされていること
    • Client ID
    • Client Secret

ゲームサーバーでゲームデータをバイナリレコードに保存する

ゲームデータをバイナリレコードに保存できるのはゲームサーバーのみです。このセクションの手順を完了することで設定できます。

ゲームバイナリレコードリクエストを作成する

まず、保存したいバイナリレコードを作成する必要があります。このプロセスから、後でバイナリファイルをアップロードするために使用される生成済みの事前署名URLを取得します。次の関数を使用してリクエストを作成できます。

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
}));

または一時的なゲームバイナリレコードリクエストを作成する

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);

バイナリファイルをアップロードする

取得した事前署名URLを使用してバイナリファイルを直接アップロードします。次の関数を使用してバイナリファイルをアップロードできます。

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
}));

コミットしてファイルの場所を更新する

バイナリファイルがアップロードされたら、変更をコミットして新しいファイルの場所が更新されるようにします。次の関数を使用します。

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
}));

ゲームサーバーからゲームバイナリレコードファイルを更新する

ゲームバイナリレコードに新しいバイナリファイルをアップロードする手順は、ゲームバイナリレコードの作成とは若干異なります。ゲームクライアントから新しいバイナリファイルをアップロードするには、このセクションの手順を完了してください。

事前署名URLをリクエストする

まず、更新されたバイナリファイルをアップロードするために使用する事前署名URLをリクエストする必要があります。次の関数を使用してリクエストできます。

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
}));

新しいバイナリファイルをアップロードする

取得した事前署名URLを使用してバイナリファイルを直接アップロードします。次の関数を使用してバイナリファイルをアップロードできます。

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
}));

再度コミットしてファイルの場所を更新する

バイナリファイルがアップロードされたら、変更をコミットして新しいファイルの場所が更新されるようにします。次の関数を使用します。

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
}));

ゲームサーバーからゲームバイナリレコードを削除する

次の関数を使用してゲームバイナリレコードを削除します。

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
}));

ゲームクライアントからゲームバイナリレコードデータを取得する

ゲームバイナリレコードデータが保存された後、プレイヤーがそのデータを取得できるようにすることができます。

単一のレコードを取得する

次の関数を使用して、キーで特定のゲームバイナリレコードデータを取得します。

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
}));

複数のレコードを取得する

次の関数を使用して、ゲームバイナリレコードのリストを取得します。

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
}));

バイナリファイルをダウンロードする

取得した事前署名URLを使用してバイナリファイルを直接ダウンロードします。次の関数を使用してバイナリファイルをダウンロードできます。

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
}));