| IQMS2WriteExtensionObject Method |
Namespace: PIX.Services.V12.Api2
Requires membership of local group QlikView Management API. |
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(); } }