InitiateUploadExtensionObject Method
Overloads
| InitiateUploadExtensionObject(Guid) | 
             Initiates an new upload of an extension object.  | 
        
      
    
InitiateUploadExtensionObject(Guid)
Initiates an new upload of an extension object.
Declaration
      ExtensionUploadHandle InitiateUploadExtensionObject(Guid qvsId)
    
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Guid | qvsId | 
           The ID of the QVS where the upload should be placed.  | 
      
Returns
| Type | Description | 
|---|---|
| ExtensionUploadHandle | 
           A handle which holds information about the upload.  | 
      
Remarks
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();
    }
}