Uploading file to WCF service

Sep 30, 2009 at 12:30 PM
Edited Sep 30, 2009 at 12:48 PM

Hi flajaxian,

First of all, great component! I've been testing many Silverlight components from codeplex and also tried using IFRAME to ajaxify my file upload ASP.NET web application and your component is far more cool.


Now, what I trying to do with this control is to get the InputStream of many files from the client's computer and upload them to a Web Service kind of like the Amazon S3. This web service also requires a session token for uploading files to a user account.


What I have done so far is create a custom adapter with a public property that contains the session token. It works perfectly but...

1. I had to also add the Service Reference to the DLL ... is there a way to create a custom adapter in a user control or some way to add the process file logic inside the web application project?

2. What would be the best way to pass in the session token to the ProcessFile method?

3. Since the progress bar only starts increasing after a file is uploaded, the progress bar will go from 0 to 100% if the user uploads only one file ... how can I display some kind of "uploading..." message or a animitated gif in the host web page or improve some how progressbar behaviour?

4. Where can I find more info on the "how to use the state" property? (Don't quite understand when they are useful)

5. I also need to get the file's full path in the client's computer because I would like to add this to the file in the server as file metadata. I am aware of the security issues on this subject but maybe this is something I can do using the state's client side set method ... right?

6. One last thing, how can I handle or re-throw an error occured while uploading a file? So far the upload control acts like the file was successfully uploaded.


Any help on this topics is very much appreciated.


Sep 30, 2009 at 4:05 PM

You can use FileReceived event and not use any adabters at all. Full path is not available from the flash player for security reasons, so there is no way to get it. If you need to present error message, use client side event http://flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToUseClientSideEvents 

Oct 1, 2009 at 7:39 PM

Hi Vlad, thanks for answering.


I moved the WCF upload logic to the FileRecieved event but now I'd like to know if there is a way to tell the user that this event finished successfully or inform any error that might occurred while uploading the file to the Web Service. Right now using JsFunc_FileStateChanged always shows state 3 before the file has even started to upload to the service.

Also the upload to the Web Service is not being reflected on the progress bar... Am I doing something wrong here?


Nov 11, 2009 at 6:12 PM
Edited Nov 11, 2009 at 6:13 PM

There is a field in the client side object called state if the value is 5 - there is an error. This is described in the same docs a little below.