question

Kim Strasser avatar image
Kim Strasser asked

PlayFabHttp does not contain a definition for SimpleGetCall and SimplePutCall

I want that the client can upload files to Title Player Account-->Files and download files from Title Player Account-->Files.

I use the code from this tutorial: https://docs.microsoft.com/en-us/gaming/playfab/features/data/entities/quickstart

But I get an error message when I use PlayFabHttp.SimpleGetCall:

PlayFabHttp does not contain a definition for SimpleGetCall
private async Task GetActualFile(PlayFab.DataModels.GetFileMetadata fileData)
{
    GlobalFileLock += 1; // Start Each SimpleGetCall

    var result = await PlayFabHttp.SimpleGetCall(
    {
        fileData.DownloadUrl
    });

    if (result.Error != null)
        Console.WriteLine(result.Error.Error.ToString());
    else
    {
        _entityFileJson[fileData.FileName] = Encoding.UTF8.GetString(result.Result);
        GlobalFileLock -= 1;
    }
}

How can I use PlayFabHttp.SimpleGetCall to download a file from Title Player Account-->Files?

And I get an error message when I use PlayFabHttp.SimplePutCall:

PlayFabHttp does not contain a definition for SimplePutCall
private async Task UploadFile(string fileName)
{
    if (GlobalFileLock != 0)
        throw new Exception("This example overly restricts file operations for safety. Careful consideration must be made when doing multiple file operations in parallel to avoid conflict.");

     ActiveUploadFileName = fileName;
     GlobalFileLock += 1; // Start InitiateFileUploads

     var result = await PlayFabDataAPI.InitiateFileUploadsAsync(new InitiateFileUploadsRequest()
     {
         Entity = new PlayFab.DataModels.EntityKey { Id = EntityID, Type = EntityType },
         FileNames = new List<string> { ActiveUploadFileName }
     });

     if (result.Error != null)
     {
         if (result.Error.Error == PlayFabErrorCode.EntityFileOperationPending)
         {
          //...      
         }
         else
             Console.WriteLine("OnSharedFailure(error): " + result.Error.Error.ToString());
     }
     else
     {
         string payloadStr;
         if (!_entityFileJson.TryGetValue(ActiveUploadFileName, out payloadStr))
         payloadStr = "{}";
         var payload = Encoding.UTF8.GetBytes(payloadStr);
         GlobalFileLock += 1; // Start SimplePutCall
        
         var resultsimpleput = await PlayFabHttp.SimplePutCall(
         {
             result.Result.UploadDetails[0].UploadUrl,
             payload,
             FinalizeUpload,
         });

         if (resultsimpleput.Error != null)
             Console.WriteLine("Error.");
         else
             Console.WriteLine("SimplePutCall.");

         GlobalFileLock -= 1; // Finish InitiateFileUploads
     }
}

How can I use PlayFabHttp.SimplePutCall to upload a file to Title Player Account-->Files?

Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

If you use PlayFab Unity SDK please make sure you have using PlayFab.Internal; before you use PlayFabHttp.SimpleGetCall and PlayFabHttp.SimplePutCall. If you usePlayFab C# SDK, PlayFab C# SDK doesn’t natively provide these two methods, youneed toimplement them by yourself.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.