Configuring SlickUpload
The SlickUpload configuration is controlled by settings in the <slickUpload> element. This topic
is a reference to the possible configuration settings.
The <uploadParser> element
This element contains settings that define where SlickUpload should hook into the ASP.NET pipeline, and whether SlickUpload
should handle all requests or use a IUploadRequestFilter to determine which requests to handle.
| Setting |
Description |
| attachEvent |
Optional string attribute.
Specifies the event SlickUpload should attach to to intercept upload requests. Possible values:
- BeginRequest – Attach at the very beginning of the pipeline. This value should only be used if there
are other HttpModules or a Global.asax in the application that conflict with SlickUpload, as any custom
classes used will not be able to access SessionState.
- PreRequestHandlerExecute – Attach right before ASP.NET processes the request. This is the default setting.
|
| requestFilter |
Optional class reference attribute.
Specifies a class that implements IUploadRequestFilter. The ShouldHandleRequest
method of this class will be called for each upload request, and processing will continue or not depending on the
return value of this method.
|
The following is an example uploadParser element with the attachEvent set to PreRequestHandlerExecute and the requestFilter
set to Namespace.ClassName, in the assembly Assembly.
<uploadParser
attachEvent="PreRequestHandlerExecute"
requestFilter="Namespace.ClassName, Assembly"
/>
The <uploadStreamProvider> element
This element contains settings that define the upload stream provider SlickUpload uses to store uploaded files. There are two built in
providers, File and SqlClient, as well as a Custom provider. The provider setting determines which provider to use.
| Setting |
Description |
| provider |
Optional UploadStreamProviderType attribute.
Specifies the IUploadStreamProvider SlickUpload should use to store uploaded files. Possible values:
- File – Use the File provider to store uploaded files in the file system. This is the default.
- SqlClient – Use the SqlClient provider to store uploaded files in a SQL Server database.
- Custom – Use a custom provider class specified in the type attribute to store uploaded files.
|
File provider
This IUploadStreamProvider writes uploaded files to the local filesystem or a share.
| Setting |
Description |
| provider |
provider="File"
|
| location |
Required string attribute.
Specifies the path to which to write upload files. Supports the ~/ application root syntax.
NOTE: The user ASP.NET is running under (by default ASPNET for XP and IIS_WPG for 2003) must
have write access to the specified path.
|
| existingAction |
Optional ExistingAction attribute.
Specifies what action to take if a file exists with the filename SlickUpload is attempting to
write to. Possible values:
- Exception – Throw an exception, terminating the upload. This is the default.
- Overwrite – Overwrite the file.
- Rename – Append a numeric suffix to the filename to make it unique.
|
| fileNameMethod |
Optional FileNameMethod attribute.
- Client – Use the name of the file from the client. This is the default.
- Guid – Generate a unique Guid for the filename.
- Custom – Use a IFileNameGenerator, specified in the fileNameGenerator attribute, to generate the filename.
|
| fileNameGenerator |
Optional class reference attribute.
Specifies a custom class that implements the IFileNameGenerator interface. Loaded when the fileNameMethod attribute is set to Custom.
|
SqlClient provider
This IUploadStreamProvider writes uploaded files to a SQL Server database.
| Setting |
Description |
| provider |
provider="SqlClient"
|
| connectionString |
Required string attribute.
Specifies the connection string to use to connect to the SQL Server database.
|
| table |
Required string attribute.
Specifies the table to write to.
|
| keyField |
Required string attribute.
Specifies the key field that identifies the record to write to.
|
| dataField |
Required string attribute.
Specifies the data field to write to.
|
| fileNameField |
Optional string attribute.
Specifies the field to which to write the file name.
|
| criteriaMethod |
Optional CriteriaMethod attribute.
- Identity – Set the key field as an identity. This is the default.
- Custom – Use a ICriteriaGenerator, specified in the criteriaGenerator attribute, to generate the key.
|
| criteriaGenerator |
Optional class reference attribute.
Specifies a custom class that implements the ICriteriaGenerator interface. Loaded when the criteriaMethod attribute is set to Custom.
|
Custom provider
A custom developer defined provider.
The <statusManager> element
This element contains settings that define the status manager SlickUpload uses to store and retrieve upload progress.
There are two built in status managers, ApplicationState and SqlClient, as well as a Custom status manager.
The provider setting determines which provider to use.
| Setting |
Description |
| provider |
Optional StatusManagerType attribute.
Specifies the IStatusManager SlickUpload should use to store and retrieve upload progress. Possible values:
- ApplicationState – Use the ApplicationState provider to store upload progress in application state. This is the default.
- SqlClient – Use the SqlClient provider to store upload progress in a SQL Server database.
- Custom – Use a custom provider class specified in the type attribute to store and retrieve upload progress.
|
| updateInterval |
Optional integer attribute.
Specifies the number of seconds between updates, or 0 for constant updates. 0 is the default.
|
ApplicationState manager
This IStatusManager stores and retrieves status from application state.
| Setting |
Description |
| manager |
manager="ApplicationState"
|
| |
There are no other settings for this provider.
|
SqlClient manager
This IStatusManager stores and retrieves status from a SQL Server database.
| Setting |
Description |
| manager |
manager="SqlClient"
|
| connectionString |
Required string attribute.
Specifies the connection string to use to connect to the SQL Server database.
|
| table |
Required string attribute.
Specifies the table to write to.
|
| keyField |
Required string attribute.
Specifies the key field that identifies the record to write to. This should be a varchar field at least as long
as the uploadIds you are using. For guid uploadIds, this should be varchar(36).
|
| statusField |
Required string attribute.
Specifies the field to which to write status data. This should be a varchar field, at least 2048 characters long.
|
| lastUpdatedField |
Required string attribute.
Specifies the field to use to store the date and time of the last status update. This should be a smalldatetime field.
|
Custom status manager
A custom developer defined status manager.
| Setting |
Description |
| manager |
manager="Custom"
|
| type |
Required class reference attribute.
Specifies a custom class that implements the IStatusManager interface.
|
These ASP.NET configuration settings are important to set so that your application can process large uploads.
| Setting |
Description |
| maxRequestLength |
Optional Integer attribute.
Specifies the limit for the input stream buffering threshold, in kilobytes. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server.
|
| executionTimeout |
Optional TimeSpan attribute.
Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.
This time-out applies only if the debug attribute in the compilation element is False. To help to prevent shutting down the application while you are debugging, do not set this time-out to a large value.
|
The following is an example httpRuntime element with the maxiumum request length set to 1 GB and the execution timeout set to 10 minutes.
<httpRuntime
maxRequestLength="1024000"
executionTimeout="600"
/>
There is an additional request length setting that must be set for IIS 7 support. See the Using SlickUpload with IIS 7 topic for more details.
|