> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hyperx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Public Storage (CDN)

> Check and download files uploaded from Console.

Public Storage distributes files every player may download, such as patches, images, balance JSON, and notice assets. Operators upload and replace files in Console. Clients read metadata and download files through the SDK.

## Flow

1. Upload a file from Console `Public Storage`.
2. Add a `tag` if you need versioned variants.
3. Check the file hash from Unity.
4. Download only when the local file is missing or the hash changed.

## Version with Tags

| Example                       | Meaning                 |
| ----------------------------- | ----------------------- |
| `Items.json`                  | Default version         |
| `Items.json` + tag `season-1` | Season-specific version |
| `Items.json` + tag `season-2` | Next season version     |

When `tag` is provided, HyperX resolves the exact version. When omitted, HyperX first looks for the untagged file, then falls back to the most recently updated version with the same filename.

## Metadata

```cs theme={null}
var meta = await HyperX.Core.PublicStorage.GetMeta("Items.json");
Debug.Log($"{meta.Hash} / {meta.Size} bytes");
```

```cs theme={null}
var meta = await HyperX.Core.PublicStorage.GetMeta("Items.json", tag: "season-2");
```

`ObjectMeta` includes hash, MIME type, size, and update time.

## Hash Only

```cs theme={null}
string hash = await HyperX.Core.PublicStorage.GetHash("Items.json");
```

## Download

To memory:

```cs theme={null}
var progress = HyperX.Core.PublicStorage.Get("Items.json");
byte[] bytes = await progress.File;
```

To Unity storage:

```cs theme={null}
var progress = HyperX.Core.PublicStorage.Get(
    "Items.json",
    "content/Items.json",
    tag: "season-2"
);

await progress.File;
```

In Unity, save paths are resolved under `Application.persistentDataPath`.

## Hash-Based Cache

```cs theme={null}
using System.IO;
using UnityEngine;

public class HyperXStorageCache : MonoBehaviour
{
    async void Start()
    {
        string fileName = "Items.json";
        string savePath = "content/Items.json";

        string remoteHash = await HyperX.Core.PublicStorage.GetHash(fileName);
        string localHash = PlayerPrefs.GetString($"HX_HASH:{fileName}");

        if (remoteHash != localHash)
        {
            var progress = HyperX.Core.PublicStorage.Get(fileName, savePath);
            await progress.File;
            PlayerPrefs.SetString($"HX_HASH:{fileName}", remoteHash);
        }

        string fullPath = Path.Combine(Application.persistentDataPath, savePath);
        string json = File.ReadAllText(fullPath);
        Debug.Log(json);
    }
}
```
