Click or drag to resize
IQMS2CloseAndInstallExtensionObject Method
Finalizes the uploads. This involves verifying that the upload is a valid package and that the installation is successful.

Namespace: PIX.Services.V12.Api2
Assembly: 
Syntax
List<QVSMessage> CloseAndInstallExtensionObject(
	ExtensionUploadHandle handle
)

Parameters

handle
Type: PIX.QMSAPI.DataObjectsExtensionUploadHandle
The handle identifying the upload.

Return Value

Type: ListQVSMessage
Messages describing the result.
Remarks
Security note Security Note

Requires membership of local group QlikView Management API.

Examples
The following code example uploads a document extension to a QVS.

The service key injection is assumed to be handled behind the scenes. For an example of how to inject the service key, see Samples.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using QMSAPI;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // create a QMS API client
            IQMS apiClient = new QMSClient();

            //retrieve a time limited service key
            ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

            //This is a valid QVS guid
            Guid qvsId = new Guid("{6afbbc64-9681-406b-8917-e78bc370a05c}");

            //Initiate the upload
            ExtensionUploadHandle handle = apiClient.InitiateUploadExtensionObject(qvsId);

            if (handle != null)
            {
                FileStream fs = new FileStream(@"C:\FlexiGrid.qar", FileMode.Open);

                int maxBufferSize = 1024 * 16;

                byte[] buffer = new byte[maxBufferSize];
                int bytesRead;

                while ((bytesRead = fs.Read(buffer, 0, maxBufferSize)) > 0)
                {
                    //Copy the read bytes into a new buffer with the same size as the number of received bytes
                    byte[] byteWireBuffer = new byte[bytesRead];
                    Buffer.BlockCopy(buffer, 0, byteWireBuffer, 0, bytesRead);

                    //Write the buffer to the QVS
                    handle = apiClient.WriteExtensionObject(handle, byteWireBuffer);        
                }

                //Finalize the upload. This will install the extension object if it is valid.
                List<QVSMessage> msg = apiClient.CloseAndInstallExtensionObject(handle);
                msg.ForEach(m => Console.WriteLine(m.Text));
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An exception occurred: " + ex.Message);
        }
        // wait for user to press any key
        Console.ReadLine();
    }
}
See Also