question

gamerishere avatar image
gamerishere asked

Several questions related to Cloud Script & CDN

Hi,

I'm struggling to find the answers to my questions for several days. Basically, I'm creating a game where players will get a "Redeemable Code" at the end of every game/level. He can play multiple times a day and have multiple "Redeemable Codes" per day. For example, let's say that my game has 10k players and each player gets 10 redeemable codes a day, which means we need a way to store 100,000 codes. The code must be stored in a secure way so that players can't read/write them. Let me write my requirements into points:

- I need to find a way to store those codes in "one place". Currently, I can grant the players the code and save it in their Player Data, because one player could store only 50 redeemable codes at any given time, so the string size in their Player Data will stay within limit. But we also need to store those 50 redeemable codes "of each player" into one place. In my example, if 2,000 players played my game and saved 50 redeemable codes in their data, the total 100,000 codes (2,000 * 50) should be stored in one place/folder.

- I need to be able to download those codes easily on a daily basis.

- I want to restrict players so that they can't read/write those codes, and instead, cloudscript handles everything.

For my requirements, I looked at the options of Player Data, but they won't work because those codes can't be stored in one place, and are not easily downloadable for us. I looked at the Entity Files but they are related to players. Again, I want to store codes in one place.

The CDN service looks like a solution. I am assuming that I can download the files and folders easily from the "File Management" tab of the Playfab Dashboard. I have the following questions regarding the CDN service:

- How is the usage calculated? Is it based on upload usage or download usage or both?

- Can I upload/write data to the CDN from Cloud Script? For example, at the end of every game, the player will send ExecuteCloudScript request from Unity and Cloud Script will generate the code, and store it in a CDN.

- For each code, a new file will be created. For example, for each code (0101CC), cloud script will save the file as "0101CC.txt", so the title of those files is the code. It means, 100,000 empty text files with only their names will be created, is it fine with the CDN?

- Can I download those files in one click if they are located in one folder? For example, a folder named "20feb2020" contain 100k or 1m files, can I download the folder in one click? Please note that the folder size will probably be a max of 50 to 100 MB, because those text files are empty and only contain the code as their title name.

- Can clients download the uploaded data in any way if I don't expose any information to them regarding the CDN? Will they be able to use GetContentUploadURL or GetContentDownloadURL APIs? I don't want to let them use these APIs. I read that those APIs are ADMIN related. Does it mean that they can only be executed on Cloud Script? I know that I've asked too many questions, but I'm hopeful that you will handle these questions beautifully and will be able to answer my questions asap.

CloudScriptContent
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

The Content Delivery Network (CDN) is an infrastructure used to deliver assets to the end-user that focuses on speed and availability. In your scenario, it seems that the CDN has some excess functions and costs.

Did you know about PlayFab Coupons? Coupons are string tokens that are generated by you, for your customers use to redeem inventory items in their game. PlayFab Coupons can be redeemed by API RedeemCoupon. The list of Coupons can be downloaded as a CSV text file. If you can determine the number of coupons you want to use at one time, you can combine PlayFab Coupons and CloudScript to achieve your "Redeemable Code" function. It should be noted that Playfab Coupons can only generate a certain number of coupons at a time, not dynamically. They can only be generated in GameManager. The number of coupons generated in a single batch cannot exceed 100. If you are an Indie, Pro, Enterprise user, you can navigate to [GameManager]-> [Contact Us](under "?" icon) (as shown in this thread) to open a ticket to apply for a larger number of coupons. Please be sure to specify the Title ID, Catalog Version, Item ID, and number needed.

If you still need to generate these coupons dynamically, Playfab's Coupons feature is not enough for you. You can generate redeemable codes according to your design, and store them in the title entity objects. Entity has not only player level but also title level. CloudScript can invoke entity API via "entity.[EntityAPIName]" statements. And players or servers need to call ExecuteEntityCloudScript to execute them. In this case, you need to call SetObjects API in CloudScript and determine the Entity field as a Title entity to access the Title entity objects. You can use the Entity API GetObjects to download this data. You can use your own administrator tool or REST API testing tool (such as Postman) to call Entity API using the Title entity token.

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.

gamerishere avatar image gamerishere commented ·

Thanks for your reply. Can I ask how many objects can be stored at the title level? I've mentioned my needs of like 100k or even 1m coupons, can we generate as many objects as we want? I read somewhere that object is limited to 500 bytes, which means each object can store like 20-30 redeemable codes. We may need thousands of objects in that case. We can manage the data with time, though. (i.e delete the old objects time to time).

I also read on your site that we can store objects as a file and there won't be any limit of file size (reasonable limit)? How to do that? Could you write an example code for me? Thank you so much!

0 Likes 0 ·
gamerishere avatar image gamerishere commented ·

OK, @Sarah Zhang I've read in the limits section that we can store only 5-10 objects depending on the plan. It definitely doesn't fulfill my needs, as each object is limited to 500-1000 bytes, which means they cannot store more than 5000 codes.

Back to the CDN question, can I create a text file with the code as title name from Cloud Script as I described in the question? For example, the code is 0101CC and I want to store it, I can simply upload the text file as 0101CC.txt, is it possible?

Is there any other storage system like web api endpoint where I could store the data initially for free and test it out? Like Google Spreadsheet from Google forms etc or any other option if there is no official solution from Playfab?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang gamerishere commented ·

>> I also read on your site that we can store objects as a file and there won't be any limit of file size (reasonable limit)? How to do that? Could you write an example code for me?

As this thread said Essentials tier has a limit of 1 File per Entity, and a total of 1GB per title. The example is in the same tutorial as the Entity Object example: https://api.playfab.com/docs/tutorials/entities/getting-started-entities.

>> Back to the CDN question, can I create a text file with the code as title name from Cloud Script as I described in the question?

Yes, it’s possible. Please check the doc Content Delivery Network quickstart for more details and examples for using CDN. Files may be uploaded and stored for free, but the use of the CDN is a paid feature and is currently charged at $0.10/GB.

>> Is there any other storage system like web api endpoint where I could store the data initially for free and test it out?

We don't have some recommend external storage, but you can use the external storage system you know to store data. Cloudscript supports using HTTP requests to access other external storage systems.

0 Likes 0 ·

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.