Transactional Uploads

Transactional Uploads are a key new feature of SA-FileUp. Transactional Uploads offer the following important advantages:

Guaranteed Synchronization with Database Transactions

Most upload applications log the upload into a database. Prior to SA-FileUp 3.0, there was no synchronization between database and file operations. Typically, an upload is processed and a file is written to the web server's hard disk. After an upload is complete, a database insert is performed to log the uploaded file. However, what happens if the database operation fails, due to a validation error for example? The uploaded file is left orphaned on the disk, with no corresponding database entry.

SA-FileUp solves this problem by automatically synchronizing the upload processing with the database transaction. If the database transaction rolls back, the upload is rolled back automatically as well, so no orphaned files are left on disk.

Similarly, if the upload fails for any reason, such as permissions problems or because of insufficient disk space, the database transaction is aborted. Your uploaded files and database entries are always synchronized.

This synchronization is available only with databases that provide transaction support via MTS, such as Microsoft SQL Server or Oracle. Microsoft Access '97 does not support transactions via MTS.

Full MTS Integration

SA-FileUp provides a complete MTS Resource Manager for uploading. The database synchronization described above works with any MTS object. This means that if you are using Microsoft Message Queue (MSMQ) or your own custom MTS objects, synchronization is still guaranteed, even if no database operations participate in the MTS transaction.

Software Artisans also provides SA-FileManagerTx, a general-purpose file management component that your can use for common file operations such as create, delete, copy, or rename. So if your application requires general-purpose transacted file operations without uploading, you can use SA-FileManagerTx. SA-FileManagerTx is a separate product from SA-FileUp and requires a separate license. Both SA-FileUp and SA-FileManagerTx are available as part of the AspStudio suite of components from Software Artisans. See http://www.aspstudio.com for more information.

Vastly Simplified Error handling and guaranteed integrity when uploading multiple files

When using a database, it is very easy to combine a sequence of steps into a transaction. The programmer can be sure that all the steps will either execute successfully, or roll back to the pre-transaction state. For example:

	BeginTransaction
	Insert Row
	Update Other Row
	CommitTransaction

Traditional ASP code for uploading does not allow this. Every action must be verified, such as:

	upl.FormEx("file1").Save
	if Err <> 0 Then
		Response.Write("Upload failed")
	Else
		upl.FormEx("file2").Save
		if Err <> 0 Then 
	...

This leads to ASP code that is either difficult to read, or has incomplete or incorrect error checking. SA-FileUp's transactional upload capability simplifies the problem significantly, as all file upload operations will complete successfully or roll back to the pre-transaction state. This ensures that when a user uploads multiple files, all of the uploaded files are written to the web server's hard disk, or no files are written at all. Best of all, the resulting code is very easy to read, yet has complete error handling.

<%@ TRANSACTION=Required LANGUAGE="VBScript" %>

<%
	set upl = Server.CreateObject ("SoftArtisans.FileUp")
	upl.Path = "d:\uploads"
	upl.FormEx("file1").Save
	upl.FormEx("file2").Save


    ' The Transacted Script Abort Handler.  This sub-routine
    ' will be called if the script transacted aborts

Sub OnTransactionAbort()
        Response.Write "<p><b>The Transaction has aborted</b>." 
        Response.Write "No uploaded files were saved."
end sub
%>

 

Previous Page Next Page