To use native PICTOFiT functionality like 2D or 3D try-on on the web, the compute server is required. It runs the algorithms for the different use cases and returns the results to the browser for displaying. Hosting of the compute server has to be done by the client. Reactive Reality doesn’t provide live instances. The following sections describe how to set it up and configure it.

This version of the Web SDK requires compute server version version 3 or higher

Pull the compute server

We will provide you with a deploy token which can be used to login to our public registry and pull images.

To authenticate to the Gitlab registry use the following command:

docker login -u <USERNAME> -p <TOKEN> registry.gitlab.com
CODE

You can then pull the latest compute server image from the registry:

docker pull registry.gitlab.com/reactivereality/public/registry/pictofitcore-web-computeserver:latest
CODE

Configuration options

After you successfully pulled the image from the registry you will not be able to run it. There are a few environment variables that can be set when running the server.

Name

Default value

Description

PORT

8000

Defines the port on which the server will be running inside the container. Make sure this port lines up with the exposed ports of the container.

AUTH_METHOD

has to be set by the user

Define what authentication method is used by the server.

Possible values:

public: No authentication is required. That means every endpoint of the server is accessible by anyone. Only recommended for testing!

static: A static auth token will be used to authenticate requests. The token used will be read from another env variable AUTHENTICATION_TOKEN. This is auth token which needs to be passed in the header of each request sent to the compute server. This token uses the bearer scheme.

CACHE_SIZE_LIMIT_BYTES

1073741824 (equals 1GB)

Defines the maximum cache limit in bytes that should be stored on the compute server.

Caching

As of version v1.6.0 content behind provided asset urls is cached into a local caching storage. Before downloading an asset, the compute server will check the Content-MD5 header of the resource url and compare it against the local cache. If the checksum matches if one of the cached ones, it will reuse this file and just otherwise download it.

If no Content-MD5 is present, the url (instead of the checksum) will be cached for 24 hours. As a consequence the compute server will not notice any changes, and also not re-download to the file behind the url it during this timeframe.

Run the compute server

Example with docker-compose.yml:

version: "3"
services:
  websdkcomputeserver:
    container_name: pictofit-computeserver
    image: registry.gitlab.com/reactivereality/public/registry/pictofitcore-web-computeserver:latest
    ports:
      - "${PORT}:${PORT}"
    env_file: .env
    restart: always
CODE

The .env file:

PORT=8000
AUTH_METHOD="static"
AUTHENTICATION_TOKEN="MY-TOKEN"
CACHE_SIZE_LIMIT_BYTES=1073741824
CODE

Boot the server up with: docker-compose up [--detach]

Usage with the SDK

The Pictofit Web SDK features a ComputeServer class that is dedicated to wrap the communication to all the endpoints of the Compute Server. This class is widely used in other higher level components like the VirtualDressingRoom.