...
align | center |
---|
...
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. In order to orchestrate the content, DryvIQ will create 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 or 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 same extension mechanism.
Creating Your First Transfer Extension
In the previous tutorial, we created a basic platform extension. We also mentioned some additional parameters that can be used to customize the project that is generated by the template. One of those parameters is --extension
. It can be used to specify the exact type of extension that you would like to create. One of the available options is --extension=transfer
that customizes the project as a transfer pipeline extension:
Code Block | ||
---|---|---|
| ||
dotnet new skysynclib --name MyTransferExtension --extension transfer |
Just as we had to do in the previous tutorial, we need to create a solution and add our new projects to it.
Code Block | ||
---|---|---|
| ||
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 a number of different methods that can be used to extend the transfer pipeline from the high-level transfer extensions API to the level operation interceptor API. In this example, we will create a transfer filter extension to automatically filter out everything except PDF files. This can be useful in trying to prevent Office files that are actively being collaborated on and only including published content in the destination.
The first step is to modify our 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. In order to modify the transfer pipeline, we first need to get access to it. This is required regardless of how we want to extend the transfer engine. We do that by adding a transfer pipeline extension.
CustomServiceExtension.cs
Code Block | ||
---|---|---|
| ||
public void ConfigureServices(IServiceCollection services) {
services.AddTransferPipelineExtension((options, src, dest, sp, pipeline) => {
// Modify the pipeline to suite our needs
return pipeline;
});
} |
This gives us access to the raw pipeline that will be used during transfer execution as well as the user-configured options and the source and destination connection instances. Since we want to apply a filter to all files, we will call an extension method that modifies the pipeline accordingly.
CustomServiceExtension.cs
Code Block | ||
---|---|---|
| ||
services.AddTransferPipelineExtension((options, src, dest, sp, pipeline) => {
pipeline.FilterItems((context, token) => Task.FromResult(context.SourceItem.PlatformName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase));
return pipeline;
}); |
Deployment
During development of this extension, it is recommended to just build the extension using dotnet build
, which will build your extension in the Debug configuration as well as copy the extension into the appropriate directory on your machine for DryvIQ to pick it 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 extension to customers then you will want to package the extension as a NuGet package (.nupkg file) using dotnet pack --configuration Release
and deploy it to a DryvIQ instance.