ACI API 26.3
ACI API Programming Guide

# Send Multipart Data

The following program provides a more detailed example that includes sending multipart data to a Media Server for processing. This example uses the aciObjectParamSetFile function to upload the source data and task configuration files.

To run this example program, you set four arguments at the command line.

    program.exe host port filepath taskconfig

where,

- `program` is the name that you use for the executable file.
- `host` is the host name or IP address of the Media Server to send the action to.
- `port` is the port of the Media Server to send the action to.
- `filepath` is the path to the source file to upload to the Media Server. This path is sent to the `SourceData` parameter in the Media Server `Process` action.
- `taskconfig` is the path to the task configuration file to upload to the Media Server. This value is sent to the `Config` parameter in the Media Server `Process` action.

For more information about the Media Server actions, refer to the Media Server Administration Guide and the Media Server Reference.

The example program runs the following steps:

1. Check the number of command-line parameters.
2. Set up a connection to Media Server, using the `host` and `port` values provided.
3. Set up a command to Media Server, using the `filepath` and `taskconfig` values provided.
4. Send the request and print the response to `stdout`.

    #include "client.h"
    #include <stdio.h>
    #include <stdlib.h>

    // Checks the value of an ACI error. If not successful, logs an error and jumps to
    //  next 'clean' label
    #define CHECK_ACI_ERROR(_nAciError) if ((_nAciError) != ACICONTENT_SUCCESS) { \
       fprintf(
          stderr, "ACI Client failed at %s:%d: %s\n", __FILE__, __LINE__,
             acioGetErrorDescription(_nAciError)
       ); \
       nRet = _nAciError; \
       goto clean;\
    }

    int main(int argc, char** argv)
    {
       int nRet = EXIT_SUCCESS;
       const char* szHostname = NULL;
       int nPort = 0;
       const char* szFilePath = NULL;
       t_aciObject* pConnection = NULL;
       t_aciObject* pCommand = NULL;
       char* szResult = NULL;
       int nBufferLength = 0;
       char* szContentType = NULL;
       const char* szTaskConfig = "task.cfg";

       // Always need to call aciInit at start of any program using ACI client lib
       aciInit();

       // 1. Checks number of command line parameters
       if (argc != 5)
       {
          fprintf(stderr, "Usage: %s HOST PORT FILEPATH TASKCONFIG\n", argv[0]);
          return -17;
       }

       szHostname = argv[1];
       nPort = atoi(argv[2]);
       szFilePath = argv[3];
       szTaskConfig = argv[4];

       // Setup connection
       CHECK_ACI_ERROR(aciObjectCreate(&pConnection, ACI_CONNECTION));
       CHECK_ACI_ERROR(aciObjectParamSetString(pConnection, ACI_HOSTNAME, szHostname));
       CHECK_ACI_ERROR(aciObjectParamSetInt (pConnection, ACI_PORTNUMBER, nPort));
       CHECK_ACI_ERROR(aciObjectParamSetInt (pConnection, ACI_CONN_RETRIES, 10));
       CHECK_ACI_ERROR(aciObjectParamSetInt (pConnection, ACI_CONN_TIMEOUT, 120000));
       CHECK_ACI_ERROR(
          aciObjectParamSetInt (pConnection, ACI_CONN_TIMEOUT_READ, 120000)
       );

       // Setup command
       CHECK_ACI_ERROR(aciObjectCreate(&pCommand, ACI_COMMAND));
       CHECK_ACI_ERROR(aciObjectParamSetBool (pCommand, ACI_COM_USE_POST, TRUE));
       CHECK_ACI_ERROR(
          aciObjectParamSetBool (pCommand, ACI_COM_USE_MULTIPART, TRUE)
       );
       CHECK_ACI_ERROR(
          aciObjectParamSetString (pCommand, ACI_COM_COMMAND, "process")
       );
       CHECK_ACI_ERROR(aciObjectParamSetBool (pCommand, "synchronous", TRUE));
       CHECK_ACI_ERROR(aciObjectParamSetFile (pCommand, "SourceData", szFilePath));
       CHECK_ACI_ERROR(aciObjectParamSetFile (pCommand, "Config", szTaskConfig));

       // Send command, get result, print result
       fprintf(stdout, "Sending process command for %s to %s:%d\n",
          szFilePath, szHostname, nPort);
       CHECK_ACI_ERROR(
          aciObjectExecuteToString(pConnection, pCommand, &szResult,
          &nBufferLength, &szContentType)
       );
       fprintf(stdout, "%s\n", szResult);

    clean:
       free(szResult); szResult = NULL;
       free(szContentType); szContentType = NULL;
       aciObjectDestroy(&pCommand);
       aciObjectDestroy(&pConnection);
       // Always need to call aciShutDown at end of any program using ACI client lib
       aciShutDown();

       return nRet;
    }

Copyright 2026 Open Text
Version 26.3 | Last updated July 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ACI API 26.3

Topic Title: Send Multipart Data