SlickUpload

Upgrading

Follow the steps below to upgrade an existing SlickUpload 5 application to SlickUpload 6. SlickUpload has changed a bit since the last version to support features like drag/drop, multiselect and upload profiles, so this upgrade is more intensive than previous upgrades. If you have a question or run into a snag during the upgrade process, post on the SlickUpload support forums or shoot us an email at support@slickupload.com and we'll help you out.

NOTES:

TIP: When you're going to copy paste the code from a code snippet below, here's the easy way: double click anywhere within the snippet box. This will select all of the code for any code snippet so you can easily copy it to the clipboard.

Upgrade Process

This upgrade guide is broken out with functional topics that describe how to upgrade each piece of your code to work with SlickUpload 6. You'll need to go through the first few topics that cover upgrading the web.config, etc., but some of the more advanced topics may not be relevant depending on which features you're using.

Upgrade steps

  1. Install the SlickUpload 6 assembly
  2. Upgrade web.config
  3. Upgrade upload stream provider config
  4. Upgrade file name generator config
  5. Upgrade criteria generator config
  6. Upgrade status manager config
  7. Upgrade server side code
  8. Upgrade custom upload stream provider code
  9. Upgrade SqlClientOutputStream/SqlClientInputStream references
  10. Upgrade page markup
  11. Upgrade Post Processing
  12. Upgrade client code

Install the SlickUpload 6 assembly

  1. Download the latest SlickUpload package from the SlickUpload download page.
  2. Select the correct Krystalware.SlickUpload.dll for your .NET framework version. The file in the /Bin-NET2 directory is for .NET 2.0, and the file in the /Bin-NET35 directory is .NET 3.5 and later. SlickUpload 6 no longer supports .NET 1.1 – if you're still on .NET 1.1, you may want to upgrade to the latest version of SlickUpload 5.
  3. Remove the old Krystalware.SlickUpload.dll from your project and add a reference to the new Krystalware.SlickUpload.dll.

Upgrade web.config

  1. Replace the entire SlickUpload <sectionGroup> registration in <configSections> with the following:

     <section name="slickUpload" type="Krystalware.SlickUpload.Configuration.SlickUploadSection, Krystalware.SlickUpload" requirePermission="false" />
  2. Create a new <slickUpload> section at the root of the web.config (after <configSections>) with the following template (don't remove your old tag just yet, as you'll be copying things from it to the new tag):

    <slickUpload>
        <uploadProfiles defaultProfile="default">
            <add name="default">
                <uploadStreamProvider />
            </add>
        </uploadProfiles>
    </slickUpload>
  3. Remove the <httpRuntime> tag from the <system.web> section (if you are using it to control SlickUpload). To set maxRequestLength and executionTimeout in SlickUpload 6, add those attributes to the <add> tag for your upload profile.
  4. Remove the SlickUpload.axd handler from <system.web>/<httpHandlers> and <system.webServer>/<handlers> if they exist.
  5. Update the SlickUpload <system.web>/<httpModule> registration as follows:
     <add name="SlickUploadModule" type="Krystalware.SlickUpload.Web.SlickUploadModule, Krystalware.SlickUpload" />
  6. Update the SlickUpload <system.webServer>/<modules> registration as follows (if it exists):
     <add name="SlickUploadModule" type="Krystalware.SlickUpload.Web.SlickUploadModule, Krystalware.SlickUpload" preCondition="integratedMode" />
  7. Run through the following topics to upgrade other parts of web.config.
  8. Once you're done upgrading web.config, remove the old <slickUpload> configuration section from the web.config

Upgrade upload stream provider config

If you have multiple handlers with different URL's, so that you can configure SlickUpload to store files differently for different pages, that concept has been made obsolete with SlickUpload 6. Instead, you can create multiple uploadProfiles and specify which to use in the SlickUpload control definition.

If you do have this case:

  1. Copy the upload profile tag created above for each handler that you have:
    <add name="default">
        <uploadStreamProvider />
    </add>
  2. Create a unique name for each upload profile
  3. Perform the following steps for each <location> tag you have configured to move the <uploadStreamProvider /> configuration into the upload profile.
  4. On your page, remove the UploadUrl attribute and add the UploadProfile attribute with the name that corresponds to the new upload profile.

If you don't have multiple handlers, perform the following steps once:

  1. Replace the <uploadStreamProvider /> tag above with the <uploadStreamProvider /> tag from your old slickUpload configuration in web.config
  2. If your provider type is not custom, rename the "provider=" attribute in the <uploadStreamProvider> tag you just replaced to be named "type="
  3. If your provider type is custom, remove the "provider=" attribute in the <uploadStreamProvider> tag
  4. If your provider type is SqlFileStream, change the type attribute to be type="SqlClient" and add the dataType="FileStream" attribute

Upgrade file name generator config

In SlickUpload 6, the IFileNameGenerator interface has been merged into the FileUploadStreamProvider. To move your logic to the correct spot:

  1. Create a new class that inherits from FileUploadStreamProvider
  2. Override the GetServerFileName method
  3. Copy your IFileNameGenerator code to the new GetServerFileName method
  4. Change the type= attribute in your tag to point to your new class (update with the reference to your new class. If your class is in App_Code, remove YourAssemblyName and the trailing comma):
     <uploadStreamProvider type="YourNamespace.YourClassName, YourAssembly" />
  5. Remove the fileNameMethod and fileNameGenerator attributes

Upgrade criteria generator config

In SlickUpload 6, the ICriteriaGenerator interface has been merged into the SqlClientUploadStreamProvider. To move your logic to the correct spot:

  1. Create a new class that inherits from SqlClientUploadStreamProvider
  2. Override the InsertRecord method
  3. Copy your ICriteriaGenerator code to the new InsertRecord method
  4. Update your code to use the passed in connection (and transaction if applicable). Using the transaction is required for SqlFileStream providers.
  5. Change the type= attribute in your tag to point to your new class (update with the reference to your new class. If your class is in App_Code, remove YourAssemblyName and the trailing comma):
     <uploadStreamProvider type="YourNamespace.YourClassName, YourAssembly" />
  6. Remove the criteriaMethod and criteriaGenerator attributes

Upgrade status manager config

  1. If you have a <statusManager> tag defined, rename it to <sessionStorageProvider> and move it from your old <slickUpload> config section to the new <slickUpload> config section.
  2. If your status manager type is not custom, rename the manager= attribute in the <sessionStorageProvider> tag you just renamed to be named type=
  3. If your status manager type is "ApplicationState", change it to "InProc"
  4. If your status manager type is "SqlServer"
    1. Delete your old SlickUpload status table and run SlickUploadStatusTable.sql to create a new table
    2. Remove the table, keyField, statusField, and lastUpdateField attributes and replace them with the following:
    3. table="SlickUploadStatus" sessionIdField="SessionId" requestIdField="RequestId" statusField="Status" lastUpdatedField="LastUpdated"
  5. If your status manager type is custom, remove the provider= attribute in the <uploadStreamProvider> tag

Upgrade server side code

Things have moved around in SlickUpload 6. To update your code to match the new locations, perform the following search and replace operations:

Old New
Krystalware.SlickUpload.ControlsKrystalware.SlickUpload.Web.Controls
Krystalware.SlickUpload.ProvidersKrystalware.SlickUpload.Storage
Krystalware.SlickUpload.StreamsKrystalware.SlickUpload.Storage.Streams
Krystalware.SlickUpload.StatusKrystalware.SlickUpload.Web.SessionStorage
UploadedFile.LocationInfo[FileUploadStreamProvider.FileNameKey]UploadedFile.ServerLocation
UploadedFile.LocationInfo[SqlClientUploadStreamProvider.IdentityIdKey]UploadedFile.ServerLocation
UploadedFile.LocationInfoUploadedFile.Data
UploadedFile.FormValuesUploadedFile.Data
UploadStatusUploadSession
UploadStatusEventArgsUploadSessionEventArgs
UploadSession.ReasonUploadSession.ErrorType

Other code details

Upgrade custom upload stream provider code

  1. The method names for IUploadStreamProvider have changed. Rename as follows:
    Old New
    GetInputStreamGetReadStream
    GetOutputStreamGetWriteStream
  2. If your UploadStreamProvider uses UploadedFile.LocationInfo, rename that to use UploadedFile.Data
  3. If your UploadStreamProvider only returns one piece of data, you can store that in UploadedFile.ServerLocation
  4. Add a constructor that accepts a parameter of type UploadStreamProviderElement. Your class will be passed the configuration section used to configure the UploadStreamProvider. You can access the configuration attributes through the Parameters collection.

Upgrade SqlClientOutputStream/SqlClientInputStream references

  1. Rename as follows:
    Old New
    SqlClientOutputStreamSqlClientReadStream
    SqlClientInputStreamSqlClientWriteStream
  2. Add a trailing parameter to the constructor call of Krystalware.SlickUpload.Storage.SqlColumnDataType.Image

Upgrade page markup

  1. Perform the following renames:
    Old New
    UplevelSelectorTemplateSelectorTemplate
    DownlevelSelectorTemplateSelectorUnskinnedTemplate
    FileTemplateFileItemTemplate
  2. For controls inside the templates, perform the following renames:
    Old New
    FileListRemoveLinkFileListRemoveCommand
    FileListFileNameFileListElement Element="FileName"
    FileListValidationMessageFileListElement Element="ValidationMessage"
    UploadProgressElement Element="FileCountText"UploadProgressElement Element="FileCount"
    UploadProgressBarElementUploadProgressBar
  3. The ShowDuringUploadElements and HideDuringUploadElements properties have been removed. If you have controls you want to hide or show during uploads, connect javascript to the OnClientUploadSessionStarted and OnClientBeforeSessionEnd events to control visibility. For example:
     <kw:SlickUpload ... OnClientUploadSessionStarted="onSessionStarted" OnClientBeforeSessionEnd="onBeforeSessionEnd" ...
     
    function onSessionStarted(data)
    {
        // TODO: show/hide elements during upload
    }
            
    function onBeforeSessionEnd(data)
    {
        // TODO: show/hide elements after upload
    }

Upgrade Post Processing

The interaction method for Post Processing has been changed slightly. To update your post processing code:

  1. Set the post processing data to the UploadSession.ProcessingStatus dictionary
  2. Remove calls to UpdatePostProcessStatus
  3. Remove the Krystalware.SlickProgress control registration directive on your page
  4. Perform the following renames:
    Old New
    ProgressBarElementUploadProgressBar
    ProgressElementUploadProgressElement
  5. Remove the HasPostProcessStep="true" attribute from the SlickUpload control
  6. Rename the OnClientProgressUpdate attribute on the SlickUpload control to OnClientUploadSessionProgress
  7. Change the client script in the OnClientUploadSessionProgress handler to use the new client API by changing this line:
     if (postProcessProgress.style.display == "none" && data.state == "PostProcessing")
    To this:
     if (data.state == "Completing" && data.percentComplete != 100)

Upgrade client code