player_data_storage - YoYoGames/GMEXT-EpicOnlineServices GitHub Wiki

Player Data Storage

Epic Online Services Interface: Player Data Storage Interface

The Player Data Storage Interface enables developers using Epic Online Services (EOS) to save encrypted, user-specific, game-specific data to cloud servers. Data that you store through this interface is accessible to the user on any device where they can log in.

The Player Data Storage Interface supports any file format; typical use cases would include saved games and replay data.

Functions

These functions are provided for handling player data storage:

Constants

These are the constants used with player data storage:

Structs

These are the structures used by this API:



Back To Top

eos_player_data_storage_copy_file_metadata_at_index

Epic Online Services Function: EOS_PlayerDataStorage_CopyFileMetadataAtIndex

This function gets the cached copy of a file's metadata by index. The metadata will be for the last retrieved or successfully saved version, and will not include any local changes that have not been committed by calling eos_player_data_storage_write_file.

Note

Requires a previous call to eos_player_data_storage_query_file_list to store values in cache.


Syntax:

eos_player_data_storage_copy_file_metadata_at_index(user_id, index)
Argument Type Description
user_id String The Product User ID of the local user who is requesting file metadata
index Real The index to get metadata for



Returns:

PlayerFileMetadata


Example:

var _count = eos_player_data_storage_get_file_metadata_count(user_id);
for(var i = 0 ; i < _count; i++)
{
    var _struct = eos_player_data_storage_copy_file_metadata_at_index(user_id, i);
    var _filename = _struct.filename;
}

The above code shows an example of how the function should be used. The player file metadata is returned providing an index.




Back To Top

eos_player_data_storage_copy_file_metadata_by_filename

Epic Online Services Function: EOS_PlayerDataStorage_CopyFileMetadataByFilename

This function creates the cached copy of a file's metadata by filename. The metadata will be for the last retrieved or successfully saved version, and will not include any changes that have not completed writing.

Note

Requires a previous call to eos_player_data_storage_query_file_list to store values in cache.


Syntax:

eos_player_data_storage_copy_file_metadata_by_filename(user_id, filename)
Argument Type Description
user_id String The Product User ID of the local user who is requesting file metadata
filename String The file's name to get metadata for



Returns:

PlayerFileMetadata


Example:

var _struct = eos_player_data_storage_copy_file_metadata_by_filename(user_id, filename);
if(_struct.status == EOS_RESULT.SUCCESS)
{
    var _filename = _struct.filename;
}

The above code shows an example of how the function should be used. The player file metadata is returned for a provided filename.




Back To Top

eos_player_data_storage_delete_cache

Epic Online Services Function: EOS_PlayerDataStorage_DeleteCache

This function clears previously cached file data. This operation will be done asynchronously. All cached files except those corresponding to the transfers in progress will be removed.

Warning

Use this with care. The cache system generally tries to clear old and unused cached files from time to time. Unnecessarily clearing the cache can degrade performance as the SDK will have to re-download data.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_delete_cache(user_id)
Argument Type Description
user_id String Product User ID of the local user who is deleting his cache



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_delete_cache"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = eos_player_data_storage_delete_cache(user_id);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_delete_cache")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_delete_file

Epic Online Services Function: EOS_PlayerDataStorage_DeleteFile

This function deletes an existing file in the cloud. If successful, the file's data will be removed from our local cache.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_delete_file(user_id, filename)
Argument Type Description
user_id String The Product User ID of the local user who authorizes deletion of the file; must be the file's owner
filename String The name of the file to delete



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_delete_file"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = eos_player_data_storage_delete_file(user_id, "MyFilename.txt");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_delete_file")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_duplicate_file

Epic Online Services Function: EOS_PlayerDataStorage_DuplicateFile

This function copies the data of an existing file to a new filename. This action happens entirely on the server and will not upload the contents of the source destination file from the host. This function paired with a subsequent eos_player_data_storage_delete_file can be used to rename a file. If successful, the destination file's metadata will be updated in our local cache.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_duplicate_file(user_id, source, destination)
Argument Type Description
user_id String The Product User ID of the local user who authorized the duplication of the requested file; must be the original file's owner
source String The name of the existing file to duplicate
destination String The name of the new file



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_duplicate_file"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_player_data_storage_duplicate_file(user_id,"myNiceFile.dat", "myNiceFile2.dat");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_duplicate_file")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_get_file_metadata_count

Epic Online Services Function: EOS_PlayerDataStorage_GetFileMetadataCount

This function gets the count of files we have previously queried information for and files we have previously read from / written to.

Note

Requires a previous call to eos_player_data_storage_query_file_list to store values in cache.


Syntax:

eos_player_data_storage_get_file_metadata_count(user_id)
Argument Type Description
user_id String The Product User ID of the local user who is requesting file metadata



Returns:

Real


Example:

var _count = eos_player_data_storage_get_file_metadata_count(user_id);
for (var i = 0 ; i < _count; i ++)
{
    var _struct = eos_player_data_storage_copy_file_metadata_at_index(user_id, i);
    var _filename = _struct.filename;
}

The above code shows an example of how the function should be used. After a successful call to eos_player_data_storage_query_file_list, the function eos_player_data_storage_get_file_metadata_count will return the number of entries in the query array which can then be accessed using the eos_player_data_storage_copy_file_metadata_at_index function.




Back To Top

eos_player_data_storage_query_file

Epic Online Services Function: EOS_PlayerDataStorage_QueryFile

This function queries a specific file's metadata, such as file names, size, and a MD5 hash of the data. This is not required before a file may be opened, saved, copied, or deleted.

Once a file has been queried, its metadata will be available by the one of the following functions:

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_query_file(user_id, filename)
Argument Type Description
user_id String The Product User ID of the local user requesting file metadata
filename String The name of the file being queried



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_query_file"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = eos_player_data_storage_query_file(user_id, "myFile.txt");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_query_file")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_query_file_list

Epic Online Services Function: EOS_PlayerDataStorage_QueryFileList

This function queries the file metadata, such as file names, size, and a MD5 hash of the data, for all files owned by this user for this application. This is not required before a file may be opened, saved, copied, or deleted. Once the callback has been fired with a successful EOS_RESULT, it is possible to call one of the following functions:

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_query_file_list(user_id)
Argument Type Description
user_id String The Product User ID of the local user who requested file metadata



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_query_file_list"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_player_data_storage_query_file_list(user_id);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_query_file_list")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_read_file

Epic Online Services Function: EOS_PlayerDataStorage_ReadFile

This function retrieves the contents of a specific file, potentially downloading the contents if we do not have a local copy, from the cloud. This request will occur asynchronously, potentially over multiple frames. All callbacks for this function will come from the same thread that the SDK is ticked from. If specified, the FileTransferProgressCallback will always be called at least once if the request is started successfully.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_read_file(user_id, filename, path)
Argument Type Description
user_id String The Product User ID of the local user who is reading the requested file
filename String The file name to read; this file must already exist
path String local path where to save the file



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_read_file"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_player_data_storage_read_file(user_id, "MyFavPic.png", "path/to/save/MyFavPic.png");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_read_file")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_write_file

Epic Online Services Function: EOS_PlayerDataStorage_WriteFile

This function writes new data to a specific file, potentially overwriting any existing file by the same name, to the cloud. This request will occur asynchronously, potentially over multiple frames. All callbacks for this function will come from the same thread that the SDK is ticked from. If specified, the FileTransferProgressCallback will always be called at least once if the request is started successfully.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_write_file(user_id, filename, path)
Argument Type Description
user_id String The Product User ID of the local user who is writing the requested file to the cloud
filename String The name of the file to write; if this file already exists, the contents will be replaced if the write request completes successfully.
path String Local path of the file to upload



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_write_file"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_player_data_storage_write_file(user_id, "myData.dat", "/path/to/file/myData.dat");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_write_file")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

eos_player_data_storage_file_transfer_request_cancel_request

Epic Online Services Function: EOS_PlayerDataStorageFileTransferRequest_CancelRequest

This function attempts to cancel this file request in progress. This is a best-effort command and is not guaranteed to be successful if the request has completed before this function is called.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

eos_player_data_storage_file_transfer_request_cancel_request(filename)
Argument Type Description
filename String Filename contained in the process to cancel



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String "eos_player_data_storage_file_transfer_request_cancel_request"
status EOS_RESULT The status code for the operation. EOS_RESULT.SUCCESS indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID

Example:

identifier = eos_player_data_storage_file_transfer_request_cancel_request("myFile.txt");

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "eos_player_data_storage_file_transfer_request_cancel_request")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

EOS_PLAYER_DATA_STORAGE_READ_RESULT

This enum holds the return results for EOS_PlayerDataStorage_OnReadFileDataCallback callbacks to return.


Member Description
CONTINUE_READING Signifies the data was read successfully, and we should continue to the next chunk if possible
FAIL_REQUEST Signifies there was a failure reading the data, and the request should end
CANCEL_REQUEST Signifies the request should be canceled, but not due to an error


Back To Top

EOS_PLAYER_DATA_STORAGE_WRITE_RESULT

This enum holds the return results for EOS_PlayerDataStorage_OnWriteFileDataCallback callbacks to return.


Member Description
CONTINUE_WRITING Signifies the data was written successfully, and we should write the data the file
COMPLETE_REQUEST Signifies all data has now been written successfully, and we should upload the data to the cloud
FAIL_REQUEST Signifies there was a failure writing the data, and the request should end
CANCEL_REQUEST Signifies the request should be canceled, but not due to an error


Back To Top

PlayerFileMetadata

The player file metadata is represented by a struct and contains metadata information for a specific player file.

This struct is referenced by the following functions:


Member Type Description
status EOS_RESULT The status of the request
status_message String A text representation of the status value
filename String The file's name
size Real The total size of the file in bytes (includes the file header in addition to the file contents)
md5_hash String The MD5 Hash of the entire file (including additional file header), in hex digits
size_unencrypted Real The size of data (payload) in file in unencrypted (original) form.
last_modified_time Real The POSIX timestamp when the file was saved last time.

⚠️ **GitHub.com Fallback** ⚠️