Web-Harvest the best, the good, the fast – way to save information

Doesn`t  matter you want to save xml file,  pictures, html or any other format of file the best way to do that is to use Java/Groovy function with Web-harvest :

A : The built-in function

I know it looks much easier to use simple built-in tag/function from WebHarvest :

<file action="write" path="${storeDir}/${attachText}.pdf" type="binary"> 
	<get var="content_you_want_to_save"> 		

BUT is not the best way – REASONS:

  • 1. Memory used – big disadvantage if you don`t have an endless memory machine :)
  • 2. Fast? well the java function is much faster than the built-in function for save

B : The Java function

<function name="saveFile" >
		<script language="groovy">
			import java.io.*;

            java.io.InputStream is = new ByteArrayInputStream(myContent.toBinary());
			java.io.BufferedInputStream getIt = new java.io.BufferedInputStream(is);
			java.io.FileOutputStream fos = new java.io.FileOutputStream( mySavePath.toString() );
	        java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
	        byte[] data = new byte[1024];
	        int x=0;
	        while((x=getIt.read(data,0,1024))>=0) {

how to call this function in WebHarvest :

<call name="saveFil2">
   <call-param name="mySavePath"><get var="filePath"/></call-param>
   <call-param name="myContent"><get var="content_you_want_to_save"/></call-param>
Posted in Web Harvest | Leave a comment

Install Proxy Certificate on Ubuntu

Open a SSH console to your Ubuntu machine and follow the steps:

1. Create a directory for proxy CA certificate in /usr/share/ca-certificates

sudo mkdir /usr/share/ca-certificates/proxy

2. Copy the ‘.crt’ file to the directory

sudo cp cert.crt /usr/share/ca-certificates/proxy/cert.crt

3. Add the ‘.crt’ file’s path relative to /usr/share/ca-certificates to /etc/ca-certificates.conf

sudo dpkg-reconfigure ca-certificates

4. Update the installed CA’s

sudo update-ca-certificates
Posted in Ubuntu | Leave a comment

Read QR Code using ZXing library in Windows Console application (C#)

1. Download the library from http://zxingnet.codeplex.com/
2. Create a new Console Application
3. Add reference zxing.dll to your project
4. Paste the following sample code (.Net 4.0) in your Program.cs file

using System;
using ZXing;
using ZXing.Common;
using System.Drawing;

namespace ZXingConsole
    class Program
        static void Main(string[] args)
            string fileName = @"d:\tmp\qr.jpg"; //test file
            if (args.Length >0)
                fileName = args[0];


        private static string GetImage(string fName)
            string ret = "";
            using (var bitmap = (Bitmap)Bitmap.FromFile(fName))
                ret = Decode(bitmap);
            return ret;

        private static string Decode(Bitmap image)
            BarcodeReader barcodeReader = new BarcodeReader
                AutoRotate = true,
                TryInverted = true,
                Options = new DecodingOptions 
                    { TryHarder = true }

            var result = barcodeReader.Decode(image);
            if (result != null)
                return "QR-Code:" + result.Text.ToUpper();

            return "ERROR";
Posted in .Net | Leave a comment