Implementing Storage or Progress Providers

The Mediachase FileUploader.NET provides a way for developers to implement custom temporary file or upload progress storage providers.

Temp File Storage Provider

The Mediachase FileUploader.NET uses a temp file storage provider to upload file before the form is submitted and keeps it available on the server. The default temp file storage provider is implemented in the LocalDiskTempFileStorageProvider class, and saves the file to the server temporary folder.

Additionally, Mediachase FileUploader.NET includes a SqlTempFileStorageProvider class, that saves the file to an MS SQL Server table of temporary files. To use the SqlTempFileStorageProvider class, first run the SqlScripts/CreateSqlTempStorage.sql on the computer with MS SQL Server, and then add a new temporary file storage provider McSqlTempFileStorageProvider into the tempFileStorage\provider section.

<tempFileStorage timeout="60" defaultProvider="McSqlTempFileStorageProvider">
       <providers>
             <add name="McLocalDiskTempFileStorageProvider"
             type="Mediachase.FileUploader.Web.LocalDiskTempFileStorageProvider, Mediachase.FileUploader"
             description=""
             tempStoragePath="%TEMP%"/>
             <add name="McSqlTempFileStorageProvider"
             type="Mediachase.FileUploader.Web.SqlTempFileStorageProvider, Mediachase.FileUploader"
             description=""
             connectionString="Data Source=(local); Initial Catalog=MC_FileUploaderTempStorage;Integrated Security=SSPI; "/>
        </providers>
</tempFileStorage>

Alternatively, you can implement your own temp file storage provider. The primary reason for creating a custom temp file storage provider is to store temporary files in any format that you require, ranging from databases to file systems.  

To implement a custom temporary file storage provider, simply create a class that inherits the TempFileStorageProvider abstract class from the Mediachase.FileUploader.Web, and then implement the abstract members that are exposed by the TempFileStorageProvider class.

The following table lists the only methods that are required to implement a custom temporary file storage provider. The TempFileStorageProvider base class provides a minimal implementation.

Method

Description

CreateStream

Creates a new temporary file stream.

CompleteStream

Completes the stream.

GetFileStreamInfo

Gets the stream information by StreamUid.

GetStream

Gets the stream by StreamUid.

GetFileStreamInfos

Gets the stream information list by SessionUid.

ReleaseStream

Releases the stream.

ReleaseSession

Releases the session.

The figure below shows the temp file storage life-time:

Upload Progress Provider

The Mediachase FileUploader.NET uses an upload progress provider to store file upload progress while files are uploading. The Default upload progress provider is implemented in the InProcessUploadProgressProvider class, to store upload progress to in-memory.

Additionally, Mediachase FileUploader.NET includes a SqlUploadProgressProvider class, to save upload progress to MS SQL Server tables. To use the SqlUploadProgressProvider class, first run the SqlScripts/CreateSqlUploadProgressStorage.sql on the the computer with MS SQL Server, and then add a new upload progress provider McSqlProgressStateProvider into the uploadProgress\provider section.

<uploadProgress timeout="60" defaultProvider="McSqlProgressStateProvider">
       <providers>
             <add name="McInProcessProgressStateProvider" type="Mediachase.FileUploader.Web.InProcessUploadProgressProvider, Mediachase.FileUploader" description=""/>
             <add name="McSqlProgressStateProvider"
        type="Mediachase.FileUploader.Web.SqlUploadProgressProvider, Mediachase.FileUploader"
        description=""
        connectionString="Data Source=(local); Initial Catalog=MC_FileUploaderTempStorage;Integrated Security=SSPI;"/>
       </providers>
</uploadProgress>

Alternatively, you can implement your own upload progress provider. The primary reason for creating a custom upload progress provider is to store upload progress in any data source that suits your requirements.

To implement a custom upload progress provider, create a class that inherits the UploadProgressProvider abstract class from the Mediachase.FileUploader.Web, and then implement the abstract members that are exposed by the UploadProgressProvider class.

The following table lists the only methods that are required to implement a custom upload progress provider. The UploadProgressProvider base class provides a minimal implementation.

Method

Description

GetInfo

Gets the upload progress information by ProgressUid.

Update

Updates the upload progress information.



Copyright 2007 Mediachase. All rights reserved.