Archive for the 'tutorial' Category

How to Use Google App Engine UrlFetch API to download the files over 1M

Nick Johnson said,

Currently, API calls are limited to 1MB, but requests and responses are limited to 10M. If you want to permit larger files, you could split them up into chunks and store them in the datastore. The 30 second request limit applies only to the time your code spends processing the request, not time sent receiving the request or sending the response.
A large file API is on our roadmap, which will make handling large files from users much easier.

I offer the UrlFetch function in my PDF Password Remover Online application, but I do not want to let it only manipulate no more 1M PDF, after some study, I got the solution, let UrlFetch API download no more 1M data each time, but repeat many times until all data downloaded, of course, there still a limit, 30 second request limit.

public static byte[] download(String url) throws IOException, InterruptedException {

ArrayList al=new ArrayList();

HttpURLConnection httpConn = null;
int seg=1024*1000;
int startPosition=0;

try {
URL u = new URL(url);

for(;;)
{
int endPosition=startPosition+seg;

httpConn = (HttpURLConnection) u.openConnection();
httpConn.setRequestMethod("GET");
httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
httpConn.setRequestProperty("Range", "bytes=" + startPosition + "-"+endPosition);
httpConn.connect();

InputStream in = httpConn.getInputStream();
byte[] b=Util.toByteArray(in);//IOUtils.toByteArray(in);
al.add(b);
startPosition+=b.length;
if(b.length break;
}
ArrayList temp = new ArrayList();
for(byte[] b : al)
{
for (int i = 0; i temp.add(b[i]);
}
}
return Util.saveBytesArrayListTobytesArray(temp);
} finally {
httpConn.disconnect();
}
}

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

How to Let iTextSharp work on DOTNET Compact Framework

Question,

I’m working on a project for pokect pc and I need to know how to use the iTextSharp API in the compact framework. Is it posible to do? or What changes can I do for making usefull the API in the compact framework?

Answer,
The compact framework is not supported but it doesn’t mean that it doesn’t work. The bouncycastle part already supports the compact framework and iTextSharp itself will need minor tweaks, see here for details.

About the iTextSharp Compact Framework 2.0 Patch,

just added compatibility for .NET Compact Framework 2.0. Attached archive
contains patchfile, VS2005 smartdevice project and two additional
compatibility classes.

Paulo, would be nice to see this in CVS; the patch was created for 4.0.1
but seems to work ok for 4.0.2 as well.
Laters,
Marco

Download iTextSharp Compact Framework 2.0 Patch here.

From:http://old.nabble.com/About-compact-Edition-td20190843.html

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

How to fix pclzip_err_bad_format issue when automatically update Piwik

Piwik 0.5.2 out, but when you try to automatically update it, you still meet pclzip_err_bad_format error. I do not want to manually update it every time, so I decide to find out the issue, from the keyword, “pclzip_err_bad_format”, I think maybe something wrong with PclZip.
The version of PclZip in Piwik is 2.8, but the last version of PclZip is 2.8.2, so I download the last version PclZip, unzip and replace the old version in Piwik, then the issue is gone.
the step in details is,
download the last version PclZip , or you can download it from here directly,

  • wget http://stat.steedsoft.com/pclzip-2-8-2.tgz
  • tar -zxfv pclzip-2-8-2.tgz
  • cp piwik/libs/PclZip/pclzip.lib.php piwik/libs/PclZip/pclzip.lib.php.org
  • cp pclzip.lib.php piwik/libs/PclZip/pclzip.lib.php
  • do the automatically update now.

P.S.
I think I had better suggest Piwik team to update PclZip, so every can easily update Piwik from next version.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride