This is a mirror of official site: http://jasper-net.blogspot.com/

Downloading in Chunks using WCF and Silverlight

| Wednesday, September 8, 2010
Acknowledgement

The project is about downloading the large file (GB) in chunks. You can download the large file with less time without getting any error. Most people use chunk in video streaming and for P2P Network. The chunk selection in P2P network is very crucial. Chunk was written to serve one purpose, and do it well: Split files into differently-sized chunks, primarily so that large files can be transported via media that is smaller than the size of the file.

Introduction

We need a functionality that can download the large file. Downloading large file in one shoot is risky so the idea is from the UI (silverlight application) user can call the WCF function to download the Chunk (let’s say 10 MB) per call. Once WCF return the Chunk data silverlight application will open the FileDialog and write the data into the stream, if the file size is grater than the chunk size, program will call the WCF function again and get the next chunk.

This way you can securely download the large file. Here we are going to use Silverlight and WCF technology.

Background

Let’s say you want to download the large file from your UI (which is running on client side) and the file is reside at server side. You can call the WCF function and get the chunk of data and write this data into the FileStream. The WCF function will be recursive so that this function will get the Chunk of data till entire file has been downloading.

Using the Code

The attached solution contains two projects, one is silverlight and other one is web project which contains the XAP file as well as Service class.

The following function is in silverlight page which calls the WCF function to get the Chunk data:

Note: you have to entered valid fileSize (size of the document in Bytes) in the code.

Read more: Codeproject

Posted via email from .NET Info

0 comments: