Screenshot of the web-based frontend
In this article I'll show you the functions and the internals of the Windows client of our free Zeta Uploader service. While this is (of course) some kind of promotion of the service itself, I'm really sure that the code discussed here could be of some value to other readers.
The download for this article enables you to completely set up a client-server scenario in your own environment, without any connection to our services.
What is Zeta Uploader?
Zeta Uploader is a central service running on our web server to which you can upload large files and let it generate e-mail messages with a download link.
The basic idea is to avoid sending files, especially large files by e-mail but instead upload it to the Zeta Uploader website and send the receiver simply a download link to the actual file.
E-mail attachments do have limitations both in size and content, since most accounts limit the maximum attachment size to some few MB. Also usually some kind of file attachments are blocked, e.g. executable files. By using Zeta Uploader, a user can avoid these limitations.
I started developing this service approximately a year ago when I was in need of sending larger files to some of our customers. Since the customer's e-mail server rejected my attachments (because of the size), I started quickly hacking together the initial website and a web form to upload a file.
I wasn't aware that there are already a few other services like mine, namely YouSendIt or RapidShare. Maybe I wouldn't have developed the service at all, if I knew these before.
Zeta Uploader has a few advantages over these other services, at least in my opinion: You don't need the create any account at all - simply upload and you're done. In addition, our service is completely free. Third, the Windows client I'm discussing in this article is a feature that the other services seems to miss, too. Last, we delete the uploaded files automatically after 30 days, which seems to be later than other services.
Please note that I don't plan to make any money from the service at all. It is simply a tool that I developed due to my own needs and which I think of as being a benefit to other users, too.
But now on to the application itself...
The components of Zeta Uploader
Zeta Uploader consists of three parts:
- A website with some web forms to upload a file through any web browser. Directly accessible at www.zeta-uploader.com
- A Windows client to install on your local machine to upload multiple files and/or folders by a few simple clicks in the Windows Explorer
- A web service with which the Windows clients communicate to upload the data
This article discusses the latter two.
The Windows client
Screenshot of the Windows-based frontend
The Windows client is a Microsoft .NET Framework 2.0 Windows Forms application, i.e. in order to use, the .NET Framework must be installed on the system.
Once installed, the user has several options to upload a file:
- Select multiple files and/or folders in Windows Explorer, then right-click and select "Send to" | "Upload with Zeta Uploader".
- Start the Windows client from the start menu and add files and folders interactively through the "add" menu item.
- Start the Windows client from the start menu and add files and folders by using drag and drop.
Once the user enters one or multiple receivers and adds an optional comment, he clicks the "Upload now" button.
All selected files and folders are locally compressed into a single ZIP file to reduce the size of the upload. After the compression, the compressed single file is uploaded via web services calls (SOAP) to the server.
The web service
The web service consists of the web service itself on the web server (ASMX file) and of the wrapper classes (the "proxy" classes) that are being used inside the Windows client to communicate with the web service.
I selected SOAP as the communication protocol (in contrast to e.g. FTP) because it has multiple benefits like really-easy development within Visual Studio .NET and since it is based on HTTP which most firewalls just easily allow to pass through.
Since I developed several upload functions inside other customer projects in the past, that are based on SOAP, too, I was aware that it is not "that" simple:
The most naive approach for uploading a file would be to have a web method like this one:
public void UploadFile( byte fileContent, string fileName );
Unfortunately this failed several times in the past: Especially when uploading large files, it is rather likely that the upload will be interrupted during the processing, due to several reasons (I remember one reason was a bloody ISA server on a heavily out-of-date server - I do hate this server personally!)
So I developed a different approach to make it more error-tolerant:
- Instead of uploading one giant block of bytes, the upload process now sends multiple smaller blocks ("chunks"), currently 50 KB per block
- In addition, each block could fail multiple times (currently 4 times) before the complete upload is being considered as failed. This allows for temporary connection problems without cancelling the complete upload
- A global retry counter limits to total number of retries so that a permanent network error is detected by the system, too
- Each uploaded block contains an ascending block number, enabling the server to detect lost packets
To encapsulate this functionality, I put the classes for the client part into a separate library called "ClientLib".
Structure of the "ClientLib" Visual Studio project
The web part is contained within the web project called "Web".
Structure of the "Web" Visual Studio project
Of course you'll find both projects in the download to this article.
Since I find it rather boring to read CodeProject articles with lot of code, I don't do this either and recommend that you simply download the article's code and open it inside Visual Studio .NET 2005.
What you can do with the code
You have several things that you could do with the code:
For example you could take the core web service communication library and put it into your own projects where you need error-tolerant upload functionality. Then you can even enhance the upload process further; e.g. in another project I implemented the ability to continue a previously interrupted upload. In yet another project I also built an error-tolerant "download", working similar to the upload of the Zeta Uploader.
Another option would be to simply take the source of the Windows client and enhance it or include it in your own application, while still communicating with the web server on "our" server. So you just enhance the client but re-use the server.
Last, you could just take the source code and build your own complete stand-alone environment where you set up your own web server and compile your own (possibly enhanced) Windows client.
And of course there are surely several other things you can do with the code that I simply cannot think of...
Web page code
Please note that I did omit the web pages from the article's download. These are the pages you see when navigating your browser to www.zeta-uploader.com. I did this, because I think that it is rather special to our own server and you'll get few, if any, benefits from downloading this code.
If you still require it, please drop me a line.
In this article I presented you the functions and some of the internals of the Zeta Uploader. I strongly hope this article is of some value and doesn't count as pure, stupid advertisement (to be honest, I'm not sure either, now after having written it...).
Anyway, I would be more than happy to get your feedback in the comments section at the end of this article. Feel free to ask your questions, provide me with suggestions and enhancements.
Of course you could use this code for whatever you want, no license or credits required (but I certainly would be glad to get a note if you developed a cool project with it).
- 2011-07-30: Updated screenshot and some minor text changes.
- 2007-05-01: Added complementary article about the content detection library.
- 2007-04-28: Initial release of the article.