0

for the past 3 days I've been trying to create an upload system for multiple files, possibly large, with progress bars.

I've been roaming the web relentlessly for the past few days, and I can say, I am now familiar with most difficulties.

sadly, all the solutions I've found online are not written c# or vbscript, in fact most of them are written in php.

I wouldn't mind switching to another language but the entire website is written in vb.net and for the sake of coherence I thought it might be best to keep with it.

File uploads: Problem 1 - progress bar: I understand file uploads will not work with ajax, since the ajax response will only occur after the file had completed its upload. I understand there is a solution using iFrames but I cannot seem to find any online examples (preferably using vb.net or c#). I understand there is another alternative using flash. how??? I also understand people are mostly against using iframes but I can't find what the reason might be.

Problem 2 - Multiple Files: I can have multiple file support with HTML5. great, but IE doesn't support it? well... IE users will just have to upload one file at a time.

Problem 3 - Large files: how? I heard something about chunking, and blobs, but these are still just random gibberish words for me. can somebody explain, the meaning and the implementation?

references to reading material are much appreciated even though, if it's on the web, I've probably already read it in my search for my solution.

Michael Seltenreich
  • 3,013
  • 2
  • 29
  • 55

1 Answers1

0

@DevlshOne has a decent thread with some good information.

Here are the three basic requirements for what I did:

  • Create Silverlight app for clientside access and upload control. (use app of your choice)
  • Create an HttpHandler to receive the data in chunks and manage requests.
  • Create the database backend to handle the files.

Silverlight worked well because I was already in VB (ASP.NET). When used in-browser, as opposed to out-of-browser, the ASP.NET session was shared with Silverlight, so there was no need to have additional security/login measures. Silverlight also allowed me to limit what file types could be selected and allow the user to select multiple files from the same folder.

The Silverlight app grabs the files selected by the user, displays them for editing of certain properties, and then begins the upload when the user clicks the 'upload' button. This sets off a number of threads that each upload chunks of data to the httphandler. The HttpHandler and Silverlight app send and receive in chunks, with the HttpHandler always sending an OK or ERROR message when the request has been processed for the uploaded chunk.

Our specific implementation of file uploading also required some database properties (fields) to be filled out by the user, so we also had inputs for those properties and uploaded them to the server with the file data.

An in-browser Silverlight app can also have parameters passed into it through the html, so I do this with settings like 'max chunk size' or 'max thread count'. I can change the setting in the database and have it apply to all users.

The database backend is basically a few stored procedures (insert your data management preference here) that control the flow of the logic. One table holds completed files (no file data), and a second holds the temp files that are in progress of being uploaded. One stored procedure initiates a new file record in the temp table and processes additional chunk uploads, and another controls the migration of the completely uploaded file from the temp table to the completed table. (A piece of VB code in the HttpHandler migrates the actual binary file data from the temp table to a physical file.)

This seems pretty complex, but the most difficult part would be the interaction with the handler and passing the chunks around (response/requests, uploading successive chunks, etc.). I left out a lot of information, but this is the basic implementation.

ps2goat
  • 8,067
  • 1
  • 35
  • 68