> For the complete documentation index, see [llms.txt](https://easyauth.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easyauth.papelship.com/csharp-document/main-functions/serverside-files.md).

# Serverside Files

The Serverside Files system enables secure distribution of dynamic modules, dependency archives, configs, and assets directly from the authentication server to authenticated clients.

## Storage & Delivery Modes

{% tabs %}
{% tab title="In-Memory Streaming (Recommended)" %}
Downloads file bytes directly into a managed `byte[]` array in RAM without touching the local disk. Ideal for sensitive dynamic DLLs, SQLite databases, and encrypted configuration packs.
{% endtab %}

{% tab title="Disk Storage Mode" %}
Downloads and writes the decrypted file directly to a specified file system path. Useful for supplementary game assets, drivers, or runtime prerequisites.
{% endtab %}
{% endtabs %}

## C# Implementation

{% tabs %}
{% tab title="Download Directly to Memory" %}

```csharp
using System;
using qPapelEasyAuth;

public class AssetLoader
{
    public static byte[]? LoadInMemoryAsset(string fileAccessId, string licenseKey, string apiKey)
    {
        Console.WriteLine($"[*] Fetching asset '{fileAccessId}' into memory...");

        // Stream file bytes over encrypted channel
        FileDownloadResult fileResult = qPapelEasyAuth.qPapelEasyAuth.GetFile(fileAccessId, licenseKey, apiKey);

        if (fileResult.Success && fileResult.Data.Length > 0)
        {
            Console.WriteLine($"[+] Download Complete: {fileResult.FileName} ({fileResult.FileSize} bytes)");
            return fileResult.Data;
        }

        Console.WriteLine($"[-] Download Failed: {fileResult.Message} ({fileResult.ErrorName})");
        return null;
    }
}
```

{% endtab %}

{% tab title="Download Directly to Disk" %}

```csharp
using System;
using qPapelEasyAuth;

public class AssetInstaller
{
    public static bool InstallPrerequisite(string fileAccessId, string targetPath, string licenseKey, string apiKey)
    {
        Console.WriteLine($"[*] Downloading file to '{targetPath}'...");

        bool success = qPapelEasyAuth.qPapelEasyAuth.DownloadFileToDisk(fileAccessId, targetPath, licenseKey, apiKey);

        if (success)
        {
            Console.WriteLine("[+] File written to disk successfully.");
            return true;
        }

        Console.WriteLine("[-] Failed to download and write file.");
        return false;
    }
}
```

{% endtab %}
{% endtabs %}

## `FileDownloadResult` Properties

| Property    | Type     | Description                                                   |
| ----------- | -------- | ------------------------------------------------------------- |
| `Success`   | `bool`   | `true` if file was retrieved and verified; otherwise `false`. |
| `FileName`  | `string` | Original file name configured on the server.                  |
| `FileSize`  | `long`   | Total byte size of the payload.                               |
| `Data`      | `byte[]` | Decrypted binary payload in memory.                           |
| `ErrorName` | `string` | Error identifier if download failed.                          |
| `Message`   | `string` | Error description.                                            |

{% hint style="warning" %}
Ensure large file downloads are executed asynchronously or on background worker threads to avoid freezing the application UI.
{% endhint %}
