Save multiple files in the cloud

Discussion and help for Easy Save 3
Post Reply
EVG
Posts: 12
Joined: Tue Dec 13, 2022 5:49 pm

Save multiple files in the cloud

Post by EVG »

Good afternoon. When using Easy Save 3, my game uses two different save files, how do I properly save both of them in the Google Play cloud? If there was only one file, it would be possible to simply translate its bytes and save, for example:

Code: Select all

byte[] savedData = ES3.LoadRawBytes();
SaveGame(savedData);
But what if you need to send two different files?
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save multiple files in the cloud

Post by Joel »

Hi there,

You use the filePath parameter of ES3.LoadRawBytes to specify which file you wish to upload. If you don't specify the filePath parameter it will get the bytes from the default file.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
EVG
Posts: 12
Joined: Tue Dec 13, 2022 5:49 pm

Re: Save multiple files in the cloud

Post by EVG »

Joel wrote: Sat Apr 29, 2023 7:27 am Hi there,

You use the filePath parameter of ES3.LoadRawBytes to specify which file you wish to upload. If you don't specify the filePath parameter it will get the bytes from the default file.

All the best,
Joel
Thanks for the reply, I understand that. But I don't understand how to make two different files into one byte array?
EVG
Posts: 12
Joined: Tue Dec 13, 2022 5:49 pm

Re: Save multiple files in the cloud

Post by EVG »

Right now I'm using two different save files. The first file saves the general settings and game currency, the second saves the gameplay, and when a new game starts, the second file is deleted. Would it be correct in this case (for normal saving in Google Play Save Cloud) to make all saves into one file? How, in this case, to completely remove all keys of the gameplay, but leaving the main settings and game currency saved? Can save keys be grouped somehow? Or how to do it correctly using Easy Save?
EVG
Posts: 12
Joined: Tue Dec 13, 2022 5:49 pm

Re: Save multiple files in the cloud

Post by EVG »

Code: Select all

//Save
	byte[] savedGameProgressData = ES3.LoadRawBytes(SaveManager.SaveDataFileName);
	ES3.Save("GameProgressData", savedGameProgressData);
	byte[] savedData = ES3.LoadRawBytes();
	SaveGame(game, savedData, new TimeSpan());

//Load
	ES3.DeleteFile();
	ES3.DeleteFile(SaveManager.SaveDataFileName);
	ES3.SaveRaw(loadedData);
	ES3.SaveRaw(ES3.Load<byte[]>("GameProgressData"), SaveManager.SaveDataFileName);
	ES3.DeleteKey("GameProgressData");
Or, for example, would such a decision be correct?
User avatar
Joel
Moodkie Staff
Posts: 4824
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save multiple files in the cloud

Post by Joel »

EVG wrote: Sat Apr 29, 2023 3:51 pm

Code: Select all

//Save
	byte[] savedGameProgressData = ES3.LoadRawBytes(SaveManager.SaveDataFileName);
	ES3.Save("GameProgressData", savedGameProgressData);
	byte[] savedData = ES3.LoadRawBytes();
	SaveGame(game, savedData, new TimeSpan());

//Load
	ES3.DeleteFile();
	ES3.DeleteFile(SaveManager.SaveDataFileName);
	ES3.SaveRaw(loadedData);
	ES3.SaveRaw(ES3.Load<byte[]>("GameProgressData"), SaveManager.SaveDataFileName);
	ES3.DeleteKey("GameProgressData");
Or, for example, would such a decision be correct?
This would indeed be a way to approach this if you wanted to merge the two files into a single file. However, personally for simplicity if I have two seperate files, I would upload them to the cloud as two seperate files to make debugging easier. This is down to personal preference though.
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply