Krystalware
SlickUpload logo

Upload Stream Provider

The upload stream provider feature allows you to connect SlickUpload to custom repositories other than the File and SQL server repositories that are built in to SlickUpload.

SlickUpload uses standard System.IO.Stream objects for its IO. When SlickUpload receives a file upload request, it calls the configured upload stream provider for each file it receives to get get a stream to which to write the upload data. It then writes all the data for that file to the stream.

Implementation

The IUploadStreamProvider interface defines three methods that must be implemented to create an upload stream provider:

  • GetInputStream

    This method should return a read only stream of the file data that was uploaded. This is used by the file.Save method to save the file to a new stream, or directly by user code.

    Note: use the identifying information stored by the GetOutputStream method in the file.LocationInfo dictionary to identify the file data to stream.

  • GetOutputStream

    This method should return a write only stream. SlickUpload will write all of the file data to this stream. This method is called for each file, just before the upload begins.

    Note: The provider should store any identifying information about the file (server filename, id, etc.) in the file.LocationInfo dictionary. This allows user code to get this information, as well as being used by the GetInputStream method.

  • RemoveOutput

    This method should remove any data written by the GetOutputStream method. It is called by SlickUpload when the upload is cancelled or terminated unexpectedly to clean up any data that may already have been written.

    Note: use the identifying information stored by the GetOutputStream method in the file.LocationInfo dictionary to identify the file data to remove.

The SlickUpload download package contains an example upload stream provider – the UploadStreamProvider sample. This sample shows how to stream uploads directly to compressed zip files using the SharpZipLib zip compression library.