Skip to main content

Title File

1. Overview

PGOS provides a file management system which manages files in title-wide. The title file information can be accessed by the game client and game server, and the game can choose to download them using the obtained URLs. However, these files can only be created, modified, or deleted via the portal console or CLI.

After completing this tutorial, you will learn the following content:

  • How to manage title file on the portal console.
  • How to query title file information in code.

2. Manage Title File

Log in to the web portal, enter the console:

image-20240628193530646

Click the Global Data link on the top, active the Title File tab:

image-20240920114030251

2.1 Create New Directory

Select the directory from the left-hand side directory tree where you wish to create a new directory, click the New Directory button to add:

image-20240701155742166

Create directory field description:

  • Name: the directory name, composed of letters, numbers, underscores(_) and hyphens(-), and it must start with a letter and cannot exceed 255 characters.

    File and Directory names are case-insensitive, meaning that "/config/rules.json" and "/CONFIG/RULES.JSON" are considered the same file.

Click the Submit button to submit the creation.

2.2 Remove Directory

Select the parent directory of the directory you want to delete from the left-hand side directory tree, and then click the Delete link to delete the directory.

image-20240920115049195

image-20240701162239434

Click the Yes button to confirm the deletion, click No to cancel the deletion.

2.3 Upload File

Select the directory from the left-hand side directory tree where you wish to upload file in, click the Upload File button:

image-20240920115608862

image-20240920120109154

Create file field description:

  • File: select the local file you want to upload to the cloud.

    Both file and directory names are case-insensitive, meaning that "/config/rules.json" and "/CONFIG/RULES.JSON" are considered the same file.

  • Server Only: specifies whether only the server has permission to obtain downloadable URL.

Click the Submit button to submit the creation.

2.4 Remove File

Expand the relevant parent directories from the left-hand side directory tree, locate the file you want to delete, and click on the "Delete" link in the list to remove the file:

image-20240920120444480

image-20240701164552924

Click the Yes button to confirm the deletion, click No to cancel the deletion.

2.5 Refresh Cache

Typically, after files are uploaded to the cloud, the cloud backend gradually synchronizes them to various region sites, so that users can download these files from nearby region caches, improving download speed. However, if you overwrite a file (delete + upload a file with the same path), due to the delayed update of regional caches, users in certain regions may still download the old cache of that file. In such case, you need to manually update the cache by clicking on the Refresh CDN Cache button below the directory tree.

image-20240920120817918

3. Query Title File Information

You can query the specified Title File item information in the game through PgosSDK.

3.1 For Game Client

APIDescription
GetTitleFileInfoQuery the title file informations of the specified file paths.

GetTitleFileInfo Client API

Interface prototype:

/**
* Query the title file informations of the specified file paths.
*
* @param Params The parameter to get title file info.
*/
void GetTitleFileInfo(
const FGetTitleFileInfoParams& Params,
TFunction<void(const FPgosResult& Ret, const FGetTitleFileInfoResult* Data)> Callback) const;

struct FGetTitleFileInfoParams
{
/**
* The list contains the full paths of title files from which information will be retrieved, with a maximum size of 100 paths.
* Note: file&folder names are case-insensitive, meaning that "/config/rules.json" and "/CONFIG/RULES.JSON" are considered the same file.
*/
TArray<FString> paths;
/**
* The valid duration(in seconds) of the file download URL, after which the URL will no longer be downloadable.
* Its value must be greater than 0, otherwise the operation will fail.
*/
int32 url_valid_time = 3600;
};

struct FGetTitleFileInfoResult
{
/** Obtained title file informations, key: file path, value: file info. */
TMap<FString, FTitleFileInfo> data;
/** The reason why the query operation failed for these paths, key: file path, value: failed reason. */
TMap<FString, FString> fails;
};

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleFile = IPgosSDKCpp::Get().GetClientTitleFileAPI();
if (TitleFile)
{
FGetTitleFileInfoParams Params;
Params.paths.Add(TEXT("/config/rules.json"));
Params.url_valid_time = 3600;
TitleFile->GetTitleFileInfo(Params, [](const FPgosResult& Ret, const FGetTitleFileInfoResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetTitleFileInfo Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetTitleFileInfo Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

3.2 For Game Server

APIDescription
GetTitleFileInfoQuery the title file informations of the specified file paths.

GetTitleFileInfo Server API

Interface prototype:

/**
* Query the title file informations of the specified file paths.
*
* @param Params The parameter to get title file info.
*/
void GetTitleFileInfo(
const FGetTitleFileInfoParams& Params,
TFunction<void(const FPgosResult& Ret, const FGetTitleFileInfoResult* Data)> Callback) const;

struct FGetTitleFileInfoParams
{
/**
* The list contains the full paths of title files from which information will be retrieved, with a maximum size of 100 paths.
* Note: file&folder names are case-insensitive, meaning that "/config/rules.json" and "/CONFIG/RULES.JSON" are considered the same file.
*/
TArray<FString> paths;
/**
* The valid duration(in seconds) of the file download URL, after which the URL will no longer be downloadable.
* Its value must be greater than 0, otherwise the operation will fail.
*/
int32 url_valid_time = 3600;
};

struct FGetTitleFileInfoResult
{
/** Obtained title file informations, key: file path, value: file info. */
TMap<FString, FTitleFileInfo> data;
/** The reason why the query operation failed for these paths, key: file path, value: failed reason. */
TMap<FString, FString> fails;
};

Example Code:

#include "PgosSDKCpp.h"

void SomeUObjectClass::SomeFunction()
{
auto TitleFile = IPgosSDKCpp::Get().GetServerTitleFileAPI();
if (TitleFile)
{
FGetTitleFileInfoParams Params;
Params.paths.Add(TEXT("/config/rules.json"));
Params.url_valid_time = 3600;
TitleFile->GetTitleFileInfo(Params, [](const FPgosResult& Ret, const FGetTitleFileInfoResult* Data) {
if (Ret.err_code == (int32)Pgos::PgosErrCode::kSuccess)
{
UE_LOG(LogTemp, Log, TEXT("GetTitleFileInfo Success"));
}
else
{
UE_LOG(LogTemp, Log, TEXT("GetTitleFileInfo Failed: err_code=%d, err_msg=%s"), Ret.err_code, *Ret.msg);
}
});
}
}

3.3 Key Errors Handling

Error CodeRelevant APIHandling Suggestion
kBackendServerValidateFailGetTitleFileInfo Client API
GetTitleFileInfo Server API
The input parameter is invalid, check error msg for detail.
kBackendAllFailedGetTitleFileInfo Client API
GetTitleFileInfo Server API
all the data to be queried failed, please check the 'fails' field to get the failure reason.
kSdkNetworkErrorAll Network APInetwork error, check error msg for detail.