Configuration
Create a files_sdk.Client with the settings it needs. A client never reads the module-level
settings, and its objects keep using it. See Clients for per-call
options, clients with your own Requests session, and closing.
The module-level functions, such as files_sdk.user.find(), use the settings on the files_sdk
module instead, as they are when each call starts.
Client Settings
| Setting | Default | Meaning |
|---|---|---|
api_key, session_id, session | The credential. With both, the API key is used. | |
workspace_id, language, headers | Sent with every API request. | |
base_url | https://app.files.com | Where the API is. See Base URL below. |
open_timeout, read_timeout | 30, 80 | Seconds to wait for a connection to each resolved address, and for each read. |
max_network_retries | 3 | Retries of a failed request; 0 sends it once. |
initial_network_retry_delay, max_network_retry_delay | 0.1, 2 | Seconds API retries wait, doubling. |
request_timeout | None | Seconds each operation may take in all. |
max_redirects | 30 | Redirects each request may follow. |
source_ip | The local address to send from. | |
verify, cert, proxies, trust_env | True, None, None, True | As for requests.Session. |
http_session | Your own requests.Session to send through. | |
transfer_limiter, upload_tuning | A limiter of its own, adaptive | See Uploads. |
region_policy, region_handler, region_development_origins | "automatic" | See Regional Relocation. |
Retries and Timeouts and Cancellation and Deadlines describe the timing settings.
Module Settings
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.
A client takes the same value as its base_url setting.
Log Level
This SDK uses the standard Python logging framework, through the files_sdk logger. The SDK
logs nothing until your application configures logging. At INFO it logs each request, response
and retry without credentials or signed URLs; at DEBUG it logs complete requests and responses,
including credentials, signed URLs and file content, so enable DEBUG only where those can be
kept safe.
Console Log Level
Also prints the SDK's messages at or above this level to stderr, however logging is configured.
Allowed values are:
- "none" (the default)
- "error"
- "warning"
- "info"
- "debug"
Open Timeout
Seconds to wait for a connection to each address the host name resolves to. The default value is 30.
Read Timeout
Read timeout in seconds, for each read of a response. The default value is 80.
Initial Network Retry Delay
Seconds before the first retry of an API request, doubling for each later retry. The default value is 0.1.
Maximum Retry Delay
Maximum network retry delay in seconds. The default value is 2.
Maximum Network Retries
Maximum number of retries after the first attempt. The default value is 3; 0 sends each request once.
Source IP
Configure the local IP address from which to send requests.