Transactional Uploads


Transactional Uploads offer the following important advantages:


Guaranteed Synchronization with Database Transactions

Most upload applications log the upload into a database. 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.

FileUpsolves 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 COM+, such as Microsoft SQL Server or Oracle.


Full COM+ Integration

SoftArtisans FileUpprovides a complete COM+ Resource Manager for uploading. The database synchronization described above works with any COM+ object. This means that if other COM+ objects in your application, synchronization is still guaranteed, even if no database operations participate in the COM+ transaction.


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:

fileUpload.FormEx("file1").Save
If Err <> 0 Then
Response.Write("Upload failed")
Else
fileUpload.Form("file2").Save
If Err <> 0 Then
...

This leads to code that is either difficult to read, or has incomplete or incorrect error checking. 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.

<%@ language="vbscript" TRANSACTION="Required" %>

<%
Set fileUpload = Server.CreateObject("SoftArtisans.FileUp")
fileUpload.Path = "d:\uploads"
fileUpload.Form("file1").Save
fileUpload.Form("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
%>

Top

Copyright © 2010 SoftArtisans, Inc. All rights reserved.