question

pixelcombats avatar image
pixelcombats asked

GetContentUploadUrl how get Directory structure?

Problem consists in to storage maps. The data structure contains the name of the map as a directory. How to get the directory names in the query? What type of MIME type to specify? Maps contained in the "City" directory. The query returns a string: Expires=1470683812&Signature=..... Query:

public void GetMapsInfo()
    {
        GetContentDownloadUrlRequest request = new GetContentDownloadUrlRequest()
        {
            Key = "City"
        };
        PlayFabClientAPI.GetContentDownloadUrl(request, (result) =>
        {
            Debug.Log("Got data:"+result.URL);
            
        }, (error) =>
        {
            Debug.Log("Got error get data");
            Debug.Log(error.ErrorDetails);
        });
    }
10 |1200

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

brendan avatar image
brendan answered

The Key specified in the call is the complete relative path to the file in question - no MIME change is required. So, for example, in our Content Management tutorial (https://playfab.com/how-use-playfabs-content-management-api/), we specify the Key as "images/well.png". So, the file in question (well.png) is stored in the sub-folder "images". When you call Admin/GetContentList, you can also specify a prefix for the lookup, which would allow you to get the files for a particular path. Finally, if you look in the Game Manager, we've added File Management under the Content tab, which also allows you to manage your Content files in a convenient directory structure display.

3 comments
10 |1200

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

pixelcombats avatar image pixelcombats commented ·

@Brendan Thank you for answer. But how to get list on Client without Admin or Server API?

0 Likes 0 ·
brendan avatar image brendan pixelcombats commented ·

Listing the content is intended as a content management feature in the current design. So, the client would either have a defined set of content its looking for, or else the items that are added to the game (new content, catalog items) would include the Keys for any content they use. For game maps, you could provide the Keys as part of a data file in your game, which you update in releases, or you could put them in Title Data, so that the players could grab them from there on sign-in.

1 Like 1 ·
pixelcombats avatar image pixelcombats commented ·

Thank you. It should help. Too bad that can not be done adding cards in 1 click. In our current system on the VPS server directory name is the name of the map in the game. Files are downloaded automatically and placed in the directory with the game. To add a map, we simply transfer the directory with the files on the server, all the rest is done automatically in the game.

0 Likes 0 ·
pixelcombats avatar image
pixelcombats answered

@Brendan Something went wrong. I got the address of the file via the request

GetContentDownloadUrlRequest - got "https://cdn.playfab.com/......". I try got the file itself. Code:

public IEnumerator GetMapFromWWW(string URL, string Dir, string MyFile)
    {
        WWW www = new WWW(URL);

        // Wait for download to complete
        yield return www;
        byte[] bytes = www.bytes;
        if (!Directory.Exists(Application.persistentDataPath + "/Maps/" + Dir)) Directory.CreateDirectory(Application.persistentDataPath + "/Maps/" + Dir);
        File.WriteAllBytes(Application.persistentDataPath + "/Maps/" + Dir + "/" + MyFile, bytes);

    }

But the file contains only that:

<?xml version="1.0" encoding="UTF-8"?><Error><Code>MissingKey</Code><Message>Missing Key-Pair-Id query parameter or cookie value</Message></Error>

10 |1200

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

brendan avatar image
brendan answered

What is the Key of the content you're attempting to download, and are you able to successfully download it using cURL?

7 comments
10 |1200

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

pixelcombats avatar image pixelcombats commented ·

@Brendan Thank you! With correct Key I get file, but received file is bigger and incorrect.filles.zip

0 Likes 0 ·
filles.zip (3.6 KiB)
brendan avatar image brendan pixelcombats commented ·

What is the Title ID you are testing, so that we can have a look?

0 Likes 0 ·
pixelcombats avatar image pixelcombats commented ·

@Brendan Title ID 2520. But problem is in the header of file. Playfab add a header to binary file:

-----------------------------28159960931270
Content-Disposition: form-data; name="FileUpload"; filename="0,0,0,.region"
Content-Type: application/octet-stream

This header added to all files uploaded to File Management.

0 Likes 0 ·
brendan avatar image brendan pixelcombats commented ·

I believe this was due to a temporary issue we had with file uploads via the Game Manager (Admin API uploads were unaffected). I just tried re-uploading your file in its original format, and it looks like that worked fine. Can you try removing any files that look like they're incorrect, re-upload, and test?

0 Likes 0 ·
pixelcombats avatar image pixelcombats brendan commented ·

@Brendan Now the wrong information:

-----------------------------28159960931270--

placed is on the end of file, file of map is still bigger and incorrect.

0 Likes 0 ·
Show more comments

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.