question

Nick H avatar image
Nick H asked

Multiple Titles which share the same Studio level CDN

Hi,

Not sure if this is the correct 'space' to post this but felt it was closest fit.

We are at the point of release with a Unity multiplayer game which will ultimately have many Titles that all relate and provide the ability for players in each title to play against each other. In order to facilitate this we build assetBundles for each title (which will also be versioned moving forward) that players on each title would need to download in order to play each other. We had assumed that the Playfab CDN was at a Studio level and so would allow us to easily upload and manage assetsBundles for all titles in the same place and also allow all titles to access the assets stored on the CDN. However when adding a new title to the studio and navigating to the Content >File Management we see that it is a separate instance. As this is game critical for us is there any way that the Playfab CDN can be used in this way?

Thanks

Content
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

Hi @Nick H,

>> As this is game critical for us is there any way that the Playfab CDN can be used in this way?

So, based on your description, the key issue here is that multiple titles don’t share the same CDN instance, which leads to multiple titles not able to access the assets in the same place. Setting up CDN instances for each title may work, but it would surely create redundancy, is that what you are concerning about? If that’s the case, I think there is a way to do this. The crucial part of accessing the asset file is to get the pre-signed URL that will authorize the download, let’s focus on that. Here are the basic steps you may take:

1)Designate a “Main” title that stores all the asset files.

2)Define a function that makes Server/GetContentDownloadUrl request to the “Main” title’s endpoint in each title and return the pre-signed URL.

3)The clients call ExecuteCloudScript to call the function and get the pre-signed URL, then use it to download the asset file.

You can also set up a custom server that makes requests to the “Main” server and return the URL to the clients, the basic idea is the same.

1 comment
10 |1200

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

Nick H avatar image Nick H commented ·

With example from @Citrus Yan using an api call from cloud script.

handlers.GetContentDownloadUrlTargetingMainTitle = function(args){
    
    let url = "https://your_main_title_id.playfabapi.com/Server/GetContentDownloadUrl";
    let method = "POST";
    let contentBody = `{"Key": "${args.Key}"}`;
    let contentType = "application/json";
    let headers = { "X-SecretKey": "your_secretkey" };
    let responseString = http.request(url, method, contentBody, contentType, headers);
    let responseJSONObj = JSON.parse(responseString);
    return (responseJSONObj.data.URL);
    
}
0 Likes 0 ·
Nick H avatar image
Nick H answered

Hi @Citrus Yan,

Thanks for replying so quickly. I understand the premise of this approach, however the GetContentDownloadUrl only takes one parameter GetContentDownloadUrlRequest which does not appear to provide a means of targeting a specific Title. As I understand it, if the function is defined in cloud script then that method is automatically tied to the title from which it is associated same goes if from the client? How would I go about targeting the 'Main' titles content with this call?

4 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.

Citrus Yan avatar image Citrus Yan commented ·

Hi @Nick H,

You can specify your "Main" title's endpoint and manually make the "POST" request to it. This code I tested below should work, you can try it out:

handlers.GetContentDownloadUrlTargetingMainTitle = function(args){
    
    let url = "https://your_main_title_id.playfabapi.com/Server/GetContentDownloadUrl";
    let method = "POST";
    let contentBody = `{"Key": "${args.Key}"}`;
    let contentType = "application/json";
    let headers = { "X-SecretKey": "your_secretkey" };
    let responseString = http.request(url, method, contentBody, contentType, headers);
    let responseJSONObj = JSON.parse(responseString);
    return (responseJSONObj.data.URL);
    
}
<br>
0 Likes 0 ·
Nick H avatar image Nick H Citrus Yan commented ·

Thanks again. Yes I started to look at using the api's for this. My only concern is whether it is 'safe' to disclose your 'secretkey' in cloud script. If it is then happy days I'll mark as the accepted answer and implement this approach. Presumably it is not possible to simply browse/access a cloud script js file out with the Playfab gamemanager?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Nick H commented ·

It is not possible to simply browse/access cloud script out with Game Manager. And, you can use roles to manage user permissions within the Game Manager to determine who in your studio will have access to the cloud script code. Secret Keys can also be created, deleted, disabled, and set to expire, you use this feature to improve security.

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.