NeatUpload with HTML controls - Working

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

NeatUpload with HTML controls - Working

Guest-856

Hello!

First of all, thank you for a great uploading solution! This is even better than many commercial solutions, and the - active - community around it makes it a truly future safe option for many site owners out there. Well done indeed!

Now for a question. I'm uploading files by using the <input type=file> html markup (since I'm generating that bit using Javascript) - and I add the "?NeatUpload_PostBackID=guid" to the querystring, then I have a AJAX function that queries status of the upload by calling a server-method that essentially does this:

[code]
string uploadId = Request.QueryString["uploadId"] ?? string.Empty; // same guid as when posting the upload (but using different name, to not confuse NeatUpload)
Brettle.Web.NeatUpload.UploadState state = Brettle.Web.NeatUpload.UploadStateStore.OpenReadOnly(uploadId);
if (state != null) {
 if (state.Status == Brettle.Web.NeatUpload.UploadStatus.Completed) {
  Response.Write("finished");
 } else {
  Response.Write(Math.Round((state.BytesRead / (double)state.BytesTotal) * 100, 0));
 }
 Brettle.Web.NeatUpload.UploadStateStore.Close(state);
} else {
 Response.Write("0");
}
[/code]

It all seem to work great. But I would like to confirm that this is a 'good' way to approach receiving status from NeatUpload? Or is there a better way?


Best Regards,
Fredrik

Reply | Threaded
Open this post in threaded view
|

Re: NeatUpload with HTML controls - Working

Dean Brettle
Administrator
Hi,

What you implemented is supported, but not the best way to do what you want.  Instead, I recommend calling the static method UploadModule.BindProgressState(), passing it your own implementation of IUploadProgressState to fill in.  You can use Brettle.Web.NeatUpload.Internal.UI.UploadProgressState as the basis for your implementation (you don't need the internal Copy() method).  The UploadModule API is designed to be used by UI components like yours.  The UploadStateStore API is designed to be used by other IUploadModule implementations (if they want).  So, by using the UploadModule API, your code will work with other UploadModules, even if they choose not to use the UploadStateStore API.

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: NeatUpload with HTML controls - Working

Guest-856
Ok! Thanks for your reply!!! Keep up the amazing work that you're doing!!