Steam User Cloud not saving

I’m trying to save SaveGames to Steam User Cloud, but the file isn’t saved.

I tried to simply save a text file first. I’m creating a test text file to make sure that it exists.
The UserCloud->WriteUserFile(*UniqueNetId, saveName, FileContents) returns true but when I check the log I have these lines:

LogOnline:Warning: STEAM: Failed to write file to Steam cloud “test.txt”.
LogOnline:Warning: Async task ‘FOnlineAsyncTaskSteamWriteUserFile bWasSuccessful:0 UserId:MySteamUserName [0x11000023141321] FileName:test.txt’ completed in 0.018661 seconds with 0

The steam implementation works as I get my steam username and we also use other steam features which work.
Am I missing something?

Thanks!

My function:

 bool SaveFileToUserCloud(FString saveName, APlayerController* Controller)
    {
    	IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
    	if (OnlineSub)
    	{
    		IOnlineUserCloudPtr UserCloud = OnlineSub->GetUserCloudInterface();
    		if (UserCloud.IsValid())
    		{
    			FString path = TEXT("SaveGames/" + saveName);
    			FString savePath = FPaths::GameSavedDir();
    			FString fullSavePath = FPaths::Combine(*(FPaths::GameSavedDir()), *path);
    			FFileHelper::SaveStringToFile(TEXT("testi"), *fullSavePath);
    			if (FFileHelper::LoadFileToArray(FileContents, *fullSavePath))
    			{
    				ULocalPlayer* LocalPlayer = Controller->GetWorld()->GetFirstLocalPlayerFromController();
    				TSharedPtr<FUniqueNetId> UniqueNetId = LocalPlayer->GetPreferredUniqueNetId();
    				UserCloud->AddOnWriteUserFileCompleteDelegate(OnWriteUserFileCompleteDelegate);
    				return UserCloud->WriteUserFile(*UniqueNetId, saveName, FileContents);
    				
    			}
    			else
    			{
    				//log error
    			}
    		}
    
    	}
    	//log error
    	return false;
    }

Is it possible you haven’t enabled cloud saves for your game with the Steam service? On their admin/landing page you have to enable that.

Do you know which line of code caused the error? Something with engine validation or an actual Steam call that is failing?

Steamworks “your id”

Hi Josh,
I have enabled cloud saves from Steam, as shown in the screenshot, so that’s not the cause.

I traced the error coming from (line 143 in OnlineUserCloudInterfaceSteam.cpp)

bool FOnlineAsyncTaskSteamWriteUserFile::WriteUserFile(const FUniqueNetId& UserId, const FString& FileToWrite, const TArray<uint8>& Contents)

Specifically this line returns false and logs the error:

if (SteamRemoteStorage()->FileWrite(TCHAR_TO_UTF8(*FileToWrite), Contents.GetData(), Contents.Num()))

From my understanding that’s the Steam call causing the error.
When I’m trying to write to file using

UserCloud->WriteUserFile(*UniqueNetId, saveName, FileContents);

the parameters are just as they should be.

Hopefully this helps with tracking down the issue. I’ll be happy to provide more details.

OK my issue was that I was giving only the filename to WriteUserFile instead of path. So giving “/MyDir/Myfile.sav” instead of “Myfile.sav” fixed the issue.

Thanks for looking into this.

Have you validated all the inputs? The filename, the amount of content and size all match?

I’m just running through a checklist. Are you logged in? Write permissions in the directory Valve stores the data locally?

Unfortunately Valve’s true/false doesn’t tell you much about why it failed. There is a cloud_log.txt file in the Steam\logs directory of your Steam client. It may have some clues as to why the write failed.

There are also some debug console commands in the Steam client for cloud. It’s been a while since I used it, but you can search for it on Valve’s site although I recall it being hard to find.

C:\SteamDev\Steam.exe -console +set_spew cloud 3 4 +log_ipc verbose remotestorage

It was such an easy API to implement that we must be missing a setting or something simple here.

Sorry for the inconvenience.

Ha, I see it was something simple :slight_smile: I didn’t think of that. Well keep the debugging cmdlines around for future use as well.

Should I pay to be a steam developer then I can enable thise feature ?

Question concerning
return UserCloud->WriteUserFile(*UniqueNetId, saveName, FileContents);
When looking at the documentation and your code I am assuming “SaveName” is the path and the “.sav” file or just the “.sav” file? Also FileContents appears to be a uint8…where are you getting the file contents?

Never mind I kinda found the answer. you are using Write to memory prior to sending it through the cloud im guessing