Configuration

Clients

A FilesClient connects to one Files.com site with one set of credentials. FilesClient.Create(config) makes an independent client. Its properties, such as client.Users or client.RemoteFiles, run operations with that client, and the objects and lists they return keep using it. Make one client for each site or user you work with; clients can be used at the same time.

Create keeps a copy of the configuration, so later changes to config do not affect the client. Create a client once and reuse it: each client has its own connection pool.

new FilesClient(config) makes the default client, which static methods such as User.Find(id) use. Making another replaces the default for later static calls, but an object keeps the client it came from. A client made this way reads config as each operation starts, so changes you make apply to operations started afterward.

Example Request

using FilesCom;
using FilesCom.Models;

var config = new FilesConfiguration();
config.BaseUrl = "https://MY-SUBDOMAIN.files.com";
config.ApiKey = "YOUR_API_KEY";

FilesClient client = FilesClient.Create(config);

try
{
    User user = await client.Users.FindAsync(id);
    await user.UpdateAsync(new Dictionary<string, object> { { "name", "New Name" } });
}
catch (FilesCom.NotAuthenticatedException e)
{
    Console.WriteLine($"Authentication Error Occurred ({e.GetType().Name}): " + e.Message);
}
catch (FilesCom.SdkException e)
{
    Console.WriteLine($"Unknown Error Occurred ({e.GetType().Name}): " + e.Message);
}

Configuration Options

Base URL

Set this to the full https:// URL of your Files.com subdomain (e.g. https://MY-SUBDOMAIN.files.com). This is not required in most cases, but one benefit of setting it is that it ensures that authentication failures will be logged to your site's API logs. Without setting this, we won't know which site to associate the authentication failure with, and it won't be logged to your site's API logs. This is always required if your site is configured to disable global acceleration. This can also be set to use a mock server in development or CI.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.BaseUrl = "https://MY-SUBDOMAIN.files.com";

Connect Timeout

Connect timeout in seconds. The default value is 30.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.ConnectTimeout = 60;

Read Timeout

Read timeout in seconds. The default value is 60.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.ReadTimeout = 90;

Initial Network Retry Delay

Initial retry delay in seconds. The default value is 0.5.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.InitialNetworkRequestDelay = 1;

Maximum Network Retries

Maximum number of retries. The default value is 3.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.MaxNetworkRetries = 5;

Maximum Retry Delay

Maximum network retry delay in seconds. The default value is 2.

Example setting

using FilesCom;

var config = new FilesConfiguration();
config.MaxNetworkRetryDelay = 5;