Player Data Storage Sample

Overview of the Player Data Storage Sample.

4 mins to read

Before You Begin

The Player Data Storage Sample uses Epic Account Services to authenticate the local user for demonstration purposes. This requires that the Client Credentials used to initialize the Epic Online Services (EOS) SDK have been assigned to an Application used for Epic Account Services.

The SDK functionality demonstrated in this sample works with any of the supported identity providers for user authentication.

Exploring the Sample

The Player Data Storage Sample is a simple file explorer for the cloud storage associated with your user account. You can log in or out with your account. While logged in, you can browse through the files associated with your account, and upload, download, duplicate, or delete those files.

The Player Data Panel

To get started with the Player Data Storage Sample, locate the Player Data panel on the right side of the user interface and log in by entering your Host Address and User Credentials (from the Developer Authentication Tool) and pressing the Log In button.

After logging in, the Player Data panel will display the list of files associated with your user account, if any exist. The Log In button will change to Log Out, and the buttons at the top of the panel will become active. The following features are available:

  • Save: Uploads the contents of the file you are currently editing to the cloud. If you close the program with unsaved changes, they will be lost.
  • Download: Downloads the selected file to the local cache and opens it in the text editor. This operation will discard any unsaved changes.
  • Duplicate: Copies the selected file. The copy will appear in the file list under the same name as the original file, with "_Copy" added to the end.
  • Delete: Deletes the selected file from the cloud.
  • Refresh: Refreshes the file list, but does not download any files.

The Console Panel

Log output from the program's operation, including the results of console commands, will appear in the text area at the top of the Console panel, which appears on the lower-left side of the user interface. In addition to clicking the buttons in the Player Data panel, you can type in console commands at the bottom of the Console panel.

The following commands are supported:

CommandArgumentsBehavior
ADDFILEFILE_NAME, FILE_DATA_PATH (optional)Creates and uploads an empty file with the name FILE_NAME, or uploads a file from the local disk (if you specify FILE_DATA_PATH)
GETFILEFILE_NAMEDownloads the specified file from the cloud
DUPFILESOURCE_FILE_NAME, DESTINATION_FILE_NAMEMakes a copy of SOURCE_FILE_NAME into a new file called DESTINATION_FILE_NAME
TESTFILEFILE_NAME, FILE_PATHRetrieves FILE_NAME from the Player Data Storage Interface and compares its contents to the local, unencrypted file at FILE_PATH
HELP(none)Prints help information about all the above commands to the console output.

You can add your own console commands in the Game::CreateConsoleCommands function in Game.cpp.

The File Panel

The File panel displays the contents of the currently-selected file (in the Player Data panel). You can edit file contents in this window before saving and uploading the file in the Player Data panel or the Console panel.

The Progress Bar Window

The file transfer operations that the Player Data Storage Sample performs are asynchronous. While performing these operations, the sample shows a the Progress Bar window, a popup with a progress bar, and a Cancel button. Users can interrupt the transfer by clicking Cancel. The sample only runs one file transfer operation at a time, although the Player Data Storage Interface can suport multiple transfer operations at once.

Exploring the Source Code

Most of the code that interacts with data files is in Samples/PlayerDataStorage/Source/PlayerDataStorage.cpp. The following functions interact with the Player Data Storage Interface directly:

Function NameBehavior
QueryListRefreshes the list of player data entries.
StartFileDataDownloadRetrieves the contents of a specific file.
StartFileDataUploadTransmits the contents of a specific file to the cloud.
AddFileUploads a new file, or overwrites an existing one.
CopyFileMakes a copy of a file.
RemoveFileDeletes a file and clears out local cache data related to it.
CancelCurrentTransferCancels the current file transfer (if any).

These functions do not use the Player Data Storage Interface directly, but do interact with related data on the local system. They can be helpful as basic guides when building your own systems to manage locally-cached information about files:

Function NameBehavior
GetFileListReturns the local file list.
SetFileListSets the local file list.
GetLocalDataReturns locally cached data for the file specified. The NoData flag is set to true when there is no data available locally.
SetLocalDataSets local data for the specified file.
EraseLocalDataErases local data for the specified file (if it exists).