question

JJ avatar image
JJ asked

Allowing User to Save Images/Audio/Video File on Playfab

Hi, I am aware that there is already another question that spoke about this, and Brendan mentioned that user are unable to upload image/audio/video file.

Since that is very long ago, may I clarify if this is still true? If yes, how can I work around it? My game allow user to send images to each other - so I have been working on SharedGroupData recently, and managed to add both the sender and receiver in a sharedgroupdata.

In this context, do I add the image within the sharedgroupdata or where should I save the image to make it logically clear that it belongs to both sender and receiver only?

P.S. Asking in advanced - if the answer is external database, may I clarify how it works? I saw a post talking about grabbing the EntityToken to which we can send to our MAMP server - but that deals with authetication. How can we make the data consistent between playfab and our external db? Suppose a new user is created using playfab, do i have to update the data in our external db?

CloudScriptShared Group DatadataCustom Game Serversgame manager
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.

JJ avatar image JJ commented ·

Adding on to this question - as I am a student doing a project for my Final Year Project, I really want to minimize my cost. I remember that Brendan mentioned the cost is $0.10 per gb downloaded - I would love to hear the updated cost and what is a realistic cost if I am merely sending <20 average size image/file/audio simply for testing and final presentation.
Cheers!

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

These days, we have the Entity File system available for arbitrary data you want to save (including binaries). So it's certainly possible for you to let clients upload any file type you like. The thing I would caution you around is that regardless of your intent, if you allow a client to upload and download arbitrary files, it's trivially easy for a hacker to repurpose your title to distribute any content they want to. Which could very rapidly run up your costs considerably. So we would strongly recommend having a server process that checks the content for validity before it is accepted. You could, for example, have a process for ingesting content that triggers an Azure Functions Cloud Script to check that content once it is uploaded, or run a custom game server that does this. You would then only allow "good" content to be finalized.

If you are sharing data between a (very) small number of players, you could use Shared Group Data, but I would recommend moving to the newer Group Entity. A Group Entity could have Entity Objects that define the Entity Files available (whether the Files belong to the player or the Group).

Costs for this would be based on usage. The $0.10 per GB downloaded cost is for CDN usage. Rather than use that, I would point you to the meters usage pricing docs:

Pricing Meters - PlayFab | Microsoft Docs

PlayFab Consumption Best Practices - PlayFab | Microsoft Docs

Those have all the details you need to work out what the costs would be, given the total usage you have in mind.

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.

JJ avatar image JJ commented ·

Hi Brendan. Thanks for the answer, I finally made good progress after looking at Entity File System. I hesitated to post a reply because I wanted to ensure I have really tried my hands on various problem first.

I'm currently able to save the file to the user's file entity, the problem I have now is regarding the naming convention. As I am trying to "link" some data along with the image (The use case is akin to PlayerA sending a picture to PlayerB with some caption)

From my research, I don't think the Entity File System actually support additional data, so what I'm trying to do now is updating the player's title data with the name of the file as the "foreign key".

Meaning my player title data would probably have something like

Message {
    "SendFrom": "PlayerA-Username", "PictureName": "myPicture", 
"SentDate": "SomeDate"
}

And my picture file would be

myPicture.

I haven't fully tested this but I'm sure this will work. However, I can't use this method continuously since the picture name is hard-coded. Do you have any suggestion how I can work around this? And is my current working method even correct?

0 Likes 0 ·
brendan avatar image brendan JJ commented ·

Yes, the Entity File system is simply that - a way to save a file (no extra metadata). But it is an arbitrary file, so why not just have the metadata for your message be in the file itself? Just add your metadata to the start or end of the file, and have the client strip that out when it downloads it? Another alternative would be to write this data into an Entity Object.

0 Likes 0 ·
JJ avatar image JJ brendan commented ·

Hmm, I'm actually saving a picture/image file, wouldn't appending the metadata affect the file?
Furthermore, since user will be able to upload these files, and enter some input (i.e. they can enter a caption for each image they send), wouldn't that be a security risk if a user writes some malicious code and I append it to the file?

Anyways
Regarding Entity Object, are you referring to writing the file data to the entity object along with the metadata, or just adding the metadata into the entity object?

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.