UGC 3

Multimedia service

As a separate application, the UGC multimedia service handles the task to manage multimedia data like audio or video

Setup

You can start the ugc multimedia service by executing ugc-multimedia.jar either directly or by calling java -jar ugc-multimedia.jar which is an executable. JVMARGS can be provided either as JAVA_OPTS in an ugc-multimedia.conf file next to the ugc-multimedia.jar or as part of the command when using java -jar ugc-multimedia.jar. The content of an ugc-multimedia.conf file might be:

JAVA_OPTS='-Xmx1g -Dlogging.config=/cms/ugc-multimedia/config/logback.xml -Dspring.config.location=/cms/ugc-multimedia/config/application.yml'

Starting the ugc multimedia service with java would look like this for the same properties:

java -Xmx1g -Dlogging.config=/cms/ugc-multimedia/config/logback.xml -Dspring.config.location=/cms/ugc-multimedia/config/application.yml -jar ugc-multimedia.jar

Configuration

The configuration of the service is done with a file called application.yml. It's written in the commonly used YAML format. In this example all values are the default values.

spring: 
  jpa: 
    hibernate: 
      ddl-auto: <mode> # database intitialization mode, e.g. update (see Spring documentation for details)
    database-platform: <org.hibernate.dialect> # org.hibernate.dialect.MySQL5InnoDBDialect or org.hibernate.dialect.Oracle12cDialect
    database: <database-type> # type of database, either mysql or oracle 
  datasource: 
    url: <url-to-database>
      # url to database which depends on the type of database, could be either jdbc:mysql://<host>:<port>/<db>?serverTimezone=UTC or jdbc:oracle:thin:@//<host>:<port>/<SID>
    username: <user> # user to access the database
    password: <pwd> # password of that user
    driver-class-name: <driver-class> # driver class to access the database, depends on type of database and may be either com.mysql.cj.jdbc.Driver or oracle.jdbc.OracleDriver 
  servlet: 
    multipart: 
      max-file-size: <file-size> # maximum size of a single file to upload, e.g. 20MB
      max-request-size: <request-size> # maximum size of all files uploaded in a single request, e.g. 20 MB
 
server : 
  port : <port> # port where the endpoints of the ugc multimedia service can be accessed
 
sophora: 
  client: 
    server-connection: 
      url: http://<host>:<port> # url to sophora server the service should connect to
      username: <sophora-user> # the user the service uses to login to sophora
      password: <sophora-pwd> # the password of the user
 
storage: 
  type: fs # type of storage to use for the multimedia files. fs for filesystem and s3 for an s3 compatible storage is supported. One of the storage options has to be configured.
  fs: # configuration for fs storage type
    baseDir: <path> # path to the location where to store files, e.g. /binaries/
#  type: s3 # example configuration for s3 storage 
#  s3:
#    accessKeyId: <accessKeyId>
#    secretAccessKey: <secretAccessKey>
#    bucketName: <bucketName>
#    host: <host>

multimedia: 
  headlineProperty: <title-property> # the title that is displayed in the document overview (sophora-content:title)
  # definition of the markers with which entries can be marked and filtered in the editorial-ui. The list can contain any number of entries
  markers: 
    - key: <key1> # unique key
      label: <label1> # the label
      colorValue: <color-value1> # a valid css color ("Red", "Blue", "#F0F8FF", ...) 
    - key: <key2>
      label: <label2> 
      colorValue: <color-value1>
 
auth: # when the following two properties are set, the requests of all endpoints starting with '/secure' will be protected with HTTP basic authentication
  username: <username>
  password: <password>
 
clamd:
  clamdHost: <clamd host> # host of the clamd service to scan multimedia uploads for viruses
  clamdPort: <clamd port> # port of the clamd service to scan multimedia uploads for viruses
  timeoutInMS: <milliseconds> # timeout in MS of the connection to the clamd service
  clamdFileStorageDir: <path> # path of the location where the file to be tested should be stored, e.g. clamdTest/ After the scan the file will be deleted.

Clamd can be configured to scan uploads for viruses. If no configuration is made, there is no virus check and all files are uploaded to your storage.

Endpoints

The documentation of the endpoints provided by the ugc multimedia service is available via swagger and can be accessed at http://<hostname>:<port>/swagger-ui.html.

For the editorial-ui a reverse proxy e.g. nginx is necessary, which ensures that requests to "/secure" go to the multimedia-service and all other requests to the already existing ugc-backend. The configuration can look like the following example:

server { 
  listen ${PROXY_PORT}; 
  location / {
    proxy_pass http://ugc-webapp:${WEBAPP_PORT}/; 
  } 
  location /websocket { 
    proxy_pass http://ugc-webapp:${WEBAPP_PORT}/websocket; 
    proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
  } 
  location /secure { 
    proxy_pass http://ugc-multimedia:${MULTIMEDIA_PORT}/secure; 
    proxy_set_header Authorization "Basic ${BASE64}";
  } 
}

Usage

The submission of multimedia is done in two steps. First, an audio or video file is uploaded via the endpoint "/public/binary". The ID returned on successful upload is used to store information for the file. This is done via the endpoint "public/multimedia". The externalId must belong to a sophora document and a file must exist for the binaryId. Furthermore the saving only works if the file has an audio or video mimetype.

The multimedia entries submitted in this way can be managed via the editorial ui, which has a new tab in the "multimedia" navigation if the addon has been activated.

Storage

There are two storage options available. With type: fs multimedia files can be saved in the filesystem. type: s3 allows them to be uploaded to an s3 compatible cloud storage. One of both storage options has to be configured. You have to configure bucketName, accessKeyId, secretAccessKey and the host.

Last modified on 12/29/20

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon