Plugin samples
Methods
Section titled “ Methods”executePluginPostReturnFile
Section titled “executePluginPostReturnFile”Description:
| Method | Return values | Description |
|---|---|---|
| executePluginPostReturnFile(String className, Dictionary<String, String> parameters, FileStream fs) | Stream | Return an Stream of execution of a class which implements RestPlugin. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;using System.IO;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host, username, password);
try { FileStream fs = new FileStream(@"D:\Testing\pluging.docx", FileMode.Open, FileAccess.Read); Dictionary<String, String> parameters = new Dictionary<String, String>(); parameters.Add("docId", "/okm:root/testPlugin.pdf"); Stream tmpFIle = ws.executePluginPostReturnFile("com.openkm.plugin.rest.TestGetDocumentRestPlugin", parameters, fs); FileStream destFile = new FileStream(@"D:\test.pdf", FileMode.OpenOrCreate); tmpFIle.CopyTo(destFile); destFile.Close(); tmpFIle.Close(); fs.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}executePluginGetReturnFile
Section titled “executePluginGetReturnFile”Description:
| Method | Return values | Description |
|---|---|---|
| executePluginGetReturnFile(String className, Dictionary<String, String> parameters) | Stream | Return the Object value of execution of a class which implements RestPlugin. |
Example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using com.openkm.sdk4csharp;using com.openkm.sdk4csharp.bean;
namespace OKMRest{ public class Program { static void Main(string[] args) { String host = "http://localhost:8180/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try { Dictionary<String, String> parameters = new Dictionary<String, String>(); parameters.Add("docId", "/okm:root/testPlugin.pdf"); Stream tmpFIle = ws.executePluginGetReturnFile("com.openkm.plugin.rest.TestGetDocumentRestPlugin", parameters); FileStream destFile = new FileStream(@"D:\test.pdf", FileMode.OpenOrCreate); tmpFIle.CopyTo(destFile); destFile.Close(); tmpFIle.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } }}