Options

Options to change nc_py_api’s runtime behavior.

Each setting only affects newly created instances of Nextcloud/NextcloudApp class, unless otherwise specified. Specifying options in kwargs has higher priority than this.

nc_py_api.options.XDEBUG_SESSION = ''

Dev option, for debugging PHP code.

nc_py_api.options.NPA_TIMEOUT: int | None = 30

Default timeout for OCS API calls. Set to None to disable timeouts for development.

nc_py_api.options.NPA_TIMEOUT_DAV: int | None = 90

File operations timeout, usually it is OCS timeout multiplied by 3.

nc_py_api.options.NPA_NC_CERT: bool | str = True

Option to enable/disable Nextcloud certificate verification.

SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either True (default CA bundle), a path to an SSL certificate file, or False (which will disable verification).

nc_py_api.options.CHUNKED_UPLOAD_V2 = True

Option to enable/disable version 2 chunked upload(better Object Storages support).

Additional information can be found in Nextcloud documentation: Chunked file upload V2

Usage examples

Using kwargs

Note

The names of the options if you wish to specify it in kwargs is lowercase.

nc_client = Nextcloud(xdebug_session="PHPSTORM", npa_nc_cert=False)

Will set XDEBUG_SESSION to "PHPSTORM" and NPA_NC_CERT to False.

With .env

Place .env file in your project’s directory, and it will be automatically loaded using dotenv

Loading occurs only once, when “nc_py_api” is imported into the Python interpreter.

Modifying at module level

Import nc_py_api and modify options by setting values you need directly in nc_py_api.options, and all newly created classes will respect that.

import nc_py_api

nc_py_api.options.NPA_TIMEOUT = None
nc_py_api.options.NPA_TIMEOUT_DAV = None

Note

In case you debugging PHP code it is always a good idea to set Timeouts to None.