Introduction

Downloadables are a pretty straight-forward feature of GameSparks. It allows developers to host static files through the platform which can be downloaded with out-of-the box requests or APIs from the client. Downloadables in GameSparks also come with a few limitations such as the size of the files which can be hosted, other platforms might have similar limitations.

In essence, Downloadables are a CDN (Content Distribution Network) which is served using AWS S3. You upload files through the portal and give them a unique code. When a player requests the file, GameSparks will request a short-lived URL where the player can download the file and return that to the player. It is then up to the client to download that file.

In this topic we will discuss how other platforms deal with their CDNs and hosting static files. Because of the simplicity of this system, it is not necessary that these alternative platforms provide a CDN or alternative feature for Downloadables. There are other options available and creating your own system is not difficult and does not require much maintenance. You can see one approach here using AWS S3 in a similar way to GameSparks.

Beamable

Beamable does not currently offer any CDN support outside of their Content feature which can be used for a wide array of static content. However, you cannot serve whole files (like Unity packages for example) using Beamable Content at the moment.

However, it is possible to create your own CDN and hook it up with Beamable using Beamable’s Microservices alternative to GameSparks Cloud-Code. There is a topic here on how to use Beamable Microservices, and another topic here on how to replicate GameSpark’s downloadables feature using AWS services.

AccelByte

AccelByte does not currently offer any CDN alternative to GameSparks’ downloadables, however it does have an alternative to GameSparks’ Uploadables feature where players can upload their own content.

We won't cover uploadables in too much detail here but you can see the APIs for AccelByte’s Slots feature here.

The process is similar to GameSparks:

  1. [Post] - Create a new slot. You can now get the URL and upload the binary into that slot
  2. [Get] Get the URL
  3. [Update] Allows you to upload/overwrite the data
  4. [Delete] Removes the data from the slot

While AccelByte does not currently have an alternative to GameSparks Downloadables it is possible to create your own CDN using AWS services. We have a guide on this here. This would require either a custom microservice or your own backend with the AccelByte Goland or JS SDK integrated. There are more details on this process in our topic on Cloud-Code here.

Nakama

Nakama does not come with an out-of-the-box feature comparable to GameSparks Downloadables or Uploadables. However, because the Nakama runtime environment is so flexible it is possible to put together your own system for Downloadables and Uploadables.

Nakama has a guide on how to achieve this with Unity here.

This guide presumes that you are already familiar with the AWS S3 service. For those who are unfamiliar we will use this topic to explain some basic setup and key points you need to know in order to set up your own S3 bucket with the Nakama guide linked above.

AWS S3 is a storage solution for files hosted by AWS. It is an infinitely scalable service which means that you can put whatever files you need into your bucket and forget about them.

Something to note about this approach and how it differs from GameSparks is that we don't have to keep to any GameSparks file-limitations with a custom S3 bucket, though there is a 5TB file limit which should be enough for most developers.

Before starting anything you will need to set up a new AWS account. We won't cover this here but it is a simple process. Just go to aws.amazon.com to sign-up.

Note - S3 storage is not free as it was in GameSparks, though it is very inexpensive. We encourage you to check out the pricing yourselves to see if it fits your game’s requirements.

S3 Setup

First we need to create a new S3 bucket for our game. In the AWS portal, navigate to the S3 service and click on the “Create Bucket” button.

There are two options at the top for the bucket name, and the region. Go ahead and fill those out. Choose a region that is closest to the majority of your players.

You’ll notice a section titled “Block Public Access settings for this bucket”. At the moment we want to leave that as it is. We only want access from Nakama for now but this is going to be granted in a different way, so we want no public access for now. For more information on bucket access policies there is a guide on that here.

Note - Bucket names must be globally unique. This means that the name you choose has to be unique across all buckets in every AWS account and across all regions. In other words something like “test1” or “myGameBucket” is not going to be allowed. The best thing to do is use something like a domain name unique to your company and your project.

Note - There are other details and settings available when you create an S3 bucket but we are going to skip those for simplicity. There is a guide here on best-practices with S3 which you can check out for more tips. One thing you could do is give your bucket some tags. Tags let you group services and instances by a common tag. This makes it easier to search for certain features and see what is connected to what, but also allows you to see which applications your bills are coming from and how much your application is costing you so we highly recommend this.

Take note of your bucket name and region of your bucket. You will need those later for your Nakama set up.

You will also need the ARN (Amazon Resource Number) of your bucket. You can access the ARN by going back to S3 and clicking on the properties tab. You will see it at the top of the page.

Uploading Files

The next thing you will need to do is upload some files.

We have a section at the bottom of this topic on exporting downloadables so the flow here would be manually uploading your GameSparks downloadables to S3. There are other ways of doing this but this method requires no additional setup.

Go ahead and upload your file. You don't need to worry about any parameters or options available when uploading the file for the moment.

Something to note is that you’ll want to use the same “shortCodes'' as you used for your GameSparks downloadables. These will become your file names in the bucket so make sure to change them if the Downloadable short-code is different to the file name so you don't have to change your code later.

Once your file is uploaded it will bring you back to your bucket menu.

Other Options

There are, of course, a lot more features to S3 than what we just covered. Updating and deleting files are things you’ll do a lot while importing your files to the new bucket. We won't cover those here as they are simple.

For a walkthrough of more complicated options and features you can check out a guide here.

Bucket Access Management

In the Nakama example (here) you can see a number of parameters are needed in order for you to communicate with your new bucket:

We got the region and bucket (the bucket name in this case) from the setup steps above so the next thing to do is to get our access key and secret. We get these values by creating a user with specific permissions to access our bucket.

IAM: Roles & Access Policy

Before we create a user we first need to create a Role and a new Access Policy.

For those unfamiliar to AWS services this might seem like extra steps but what we are doing with IAM and creating this user is defining what services a user can access. We can create policies which define the specific terms of use of a group of resources or, in our case, narrow it to a specific bucket. We can group multiple policies into a Role. Once a Role is applied to a user we know exactly what that user can access in our AWS account.

We do this to make our account as secure as possible when granting permissions to external tools like Nakama.

We will therefore be restricting our policies to only what Nakama’s example requires which are get (returning the URL for the file) and put (uploading a file) permissions.

Create Role & Policy

To create a new Role you will need to find the “IAM” service (Identity & Access Management) in your AWS dashboard.

From the menu on the left-hand side of the page click on “Roles” and create a new Role. Click on “S3” from the list of services presented and then on the “Next” button at the bottom of the page.

On the next page, click on the “Create Policy” button. There is a visual editor here but for our case we already know the permissions we need so we are going to add the following JSON.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject"
            ],
            Resource": "arn:aws:s3:::<the-arn-of-your-bucket>"
        }
    ]
}

You will need to use the ARN of your bucket as we mentioned earlier.

Now you can click the “Next” button at the bottom and give your Policy some tags if you want.

Give your Policy a name and description and create the Policy.

Now you can go back to the tab where we left off creating our Role. If you refresh the policy list you should find your new policy. Select that and add it to the Role. Add some tags if you wish, give your Role a name and then create it.

New User

Next we need to create a new user and assign this Role to them. You can create a new user by going to the Users option on the left-hand menu of the IAM page.

Click on the “Add users” button on the top-right of the page.

Give your user a name and make sure you click on the “Programmatic Access” Type. This is where we get the key and secret from. Other users created in IAM would give access to your AWS account and services through the same portal use are using to set this user up, but this user only has access via Nakama.

Click on the “Next” button at the bottom of the page. Now we need to assign this user the Policy we created. To do this, click on the tab to attach existing policies directly. Now you can search for your Nakama policy and add it.

Now continue to create the new user.

The last screen will show you that your user has been created successfully. Take note of the access key ID and the secret for your key.

Now you have everything you need to get the Nakama guide working for your own game.

Exporting & Importing Files

Depending on the volume of files you need to import into your new bucket, this task could be as simple as downloading files from the GameSparks portal and then re-uploading them to your new S3 bucket. A large number of files or larger files might make this a lengthy process.

In a case where you have a large volume of files to tranisition you might consider using the GameSparks REST API to extract the files you need and then automatically upload them to S3 using the AWS S3 CLI (command line interface). The AWS CLI provides a set of APIs that allow you to control files in your buckets.