My company is investigating the ajax uploader as a possible solution for our site. Our requirements are that it needs to be able to use sqlfilestream on the backend with no temporary files on the server. I've been able to get it working perfectly using a custom uploadprovider which copies the data off of the incoming stream onto a sql filestream.
The problem that I'm running into is how to detect that a file upload is cancelled. Because sql filestream runs within a transaction, I need to be able to roll back that transaction if the cancel uploads button is clicked on the client. Does anyone know how to accomplish this?
Some more details about my environment:
Because the upload provider gets disposed and recreated for each chunk of data coming over the wire, I have a singleton class which controls all filestream operations. In the upload provider - I pass along the correct arguments to the singleton, allowing it to perform the correct action. Also, I'm not sure if it's relevant, but I have the client control set to manually start uploads.
Based on what I have seen, it appears that the "Persist" function in the upload provider is equivalent to saying "The file upload is complete, go ahead and commit your transaction". So that's where I've been performing the transaction commit.
However, I assumed that the "unpersist" function would then be the equivalent of a "cancel", so that's where I attempted to put my transaction rollback code -- But I can't find anything that actually calls the unpersist function.
Clearly I'm missing something - can someone fill me in on:
A) How to detect a cancel event in the upload provider
B) What are persist / unpersist actually for? I'm having a hard time understanding what these methods are intended to do.