FileNameGenerator Sample
To see this sample in action, download the SlickUpload package and configure it for your environment.
NOTE: the maximum allowed request size for this sample is 1000 MB. If you attempt to upload files larger than this,
you will recieve a oversized upload error which SlickUpload will handle gracefully. This is controlled by the maxRequestLength attribute of the
httpRuntime key in the web.config file.
Description
This sample demonstrates how to control and generate server filenames for files as they are uploaded. This is accomplished by using a FileNameGenerator. In this sample,
the filename is generated by putting the file in a folder named for the first letter of the client filename. For more useful filename generators, you might use other information. For example:
- The currently logged in username (available via HttpContext.Current.User.Identity.Name)
- Data stored in session state (available via HttpContext.Current.Session)
- Data passed via the UploadInformation string (accessible via HttpUploadModule.GetUploadStatus().UploadInformation)
To configure SlickUpload to use a FileNameGenerator, you set the following uploadStreamProvider key attributes:
- fileNameMethod="Custom"
- fileNameGenerator="<class reference to your FileNameGenerator>"
For this sample, the configuration is as follows:
<uploadStreamProvider ... fileNameMethod="Custom" fileNameGenerator="PrefixFolderFileNameGeneratorCS" ... />
|