Creating Custom Transfer Extensions
Add custom behavior to your DryvIQ Platform using transfer extensions.
Table of Contents
Prerequisites
- .NET Core SDK
- .NET IDE of choice
- Access to the DryvIQ SDK packages
- DryvIQ SDK custom project template
- Basic understanding of creating a DryvIQ Platform extension
Getting Started
The DryvIQ Platform allows users to connect to on-premise and cloud storage platforms and orchestrate the content contained within those platforms. To orchestrate the content, DryvIQ creates a pipeline that facilitates pulling content from a source and transferring it to a destination. This pipeline can be configured based on user-configured options and available custom extensions. This creates an opportunity for extension developers to contribute to this pipeline to facilitate custom behavior, such as manipulating permissions and custom metadata or transforming content from one format to another. In fact, a large majority of functionality within the transfer engine is built using this exact extension mechanism.
Creating Your First Transfer Extension
The --extension can be used to specify the exact type of extension you would like to create. One of the available options is --extension=transfer, which customizes the project as a transfer pipeline extension:
dotnet new skysynclib --name MyTransferExtension --extension transfer
As you had to do with other custom work, you need to create a solution and add our new projects.
cd MyTransferExtension
dotnet new solution
dotnet sln add src\MyTransferExtension\MyTransferExtension.csproj
dotnet sln add test\MyTransferExtension.Tests\MyTransferExtension.Tests.csproj
Creating a Transfer Filter Extension
There are several different methods that can be used to extend the transfer pipeline from the high-level transfer extensions API to the level operation interceptor API. The following examples show how to create a transfer filter extension to filter out everything except PDF files. This type of filtering can be useful when trying to prevent the transfer of Microsoft Office files that are actively being collaborated on to ensure only published content will be in the destination.
The first step is to modify the CustomServiceExtension class, which derives from IServiceCollectionExtension. Extensions of this type are automatically picked up and called while DryvIQ is starting up. This allows extension developers to register services with the same dependency injection container that DryvIQ uses. You must get access to the transfer pipeline to modify it. This is required regardless of how you want to extend the transfer engine. You do that by adding a transfer pipeline extension.
CustomServiceExtension.cs
public void ConfigureServices(IServiceCollection services) {
services.AddTransferPipelineExtension((options, src, dest, sp, pipeline) => {
// Modify the pipeline to suite your needs
return pipeline;
});
}
This gives us access to the raw pipeline used during transfer execution, the user-configured options, and the source and destination connection instances. To apply filters, for example, call an extension method that modifies the pipeline accordingly.
CustomServiceExtension.cs
services.AddTransferPipelineExtension((options, src, dest, sp, pipeline) => {
pipeline.FilterItems((context, token) => Task.FromResult(context.SourceItem.PlatformName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase));
return pipeline;
});
Deployment
During the development of this custom connector, DryvIQ recommends building the project using dotnet build. This will build using the Debug configuration and copy the connector into the appropriate directory on your machine for DryvIQ to pick up (if you have a local copy that you can use to test live within the product). However, once you are ready to deploy this connector to customers, you will want to package it as a NuGet package (.nupkg file) using dotnet pack --configuration Release and deploy it to a DryvIQ instance.