WriteExtensionObject Method
Overloads
| WriteExtensionObject(ExtensionUploadHandle, Byte[]) | 
             Uploads a piece of an extension object. The handle returned contains the current state of the upload.  | 
        
      
    
WriteExtensionObject(ExtensionUploadHandle, Byte[])
Uploads a piece of an extension object. The handle returned contains the current state of the upload.
Declaration
      ExtensionUploadHandle WriteExtensionObject(ExtensionUploadHandle handle, byte[] chunk)
    
  Parameters
| Type | Name | Description | 
|---|---|---|
| ExtensionUploadHandle | handle | 
           The handle which identifies the upload.  | 
      
| System.Byte[] | chunk | 
           The data to upload.  | 
      
Returns
| Type | Description | 
|---|---|
| ExtensionUploadHandle | 
           A handle which contains the current state of the upload.  | 
      
Remarks
An upload usually requires several calls to this method and it is very important that the handle used is the handle which was returned from the last successful call.
security
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.
    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();
    }
}