1

I am currently evaluating ImageFlow Server (https://github.com/imazen/imageflow-dotnet-server) to determine if it will meet the needs of a project that I am working on. Working through the documentation, I was able to get the ImageFlow Server connected to Azure Storage using the following:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddImageflowAzureBlobService(
            new AzureBlobServiceOptions("[MY CONNECTION STRING TO AZURE STORAGE]",
                    new BlobClientOptions())
                .MapPrefix("/azure", "[CONTAINER No. 1]"));
    }

This works without issue and I can see images as expected. Current requirements for the project requires that each user will have a unique container though, which makes the implementation above impossible.

Is there a way to pass the container name along with the file name when making a request? Something like: '/azure/CONTAINER/image.jpg?w=250'

mfree
  • 80
  • 1
  • 7

1 Answers1

2

We have an example provider to do exactly that here: https://github.com/imazen/imageflow-dotnet-server/blob/main/examples/Imageflow.Server.Example/CustomBlobService.cs

// Custom blob services can do whatever you need. See CustomBlobService.cs in src/Imageflow.Service.Example
            services.AddImageflowCustomBlobService(new CustomBlobServiceOptions()
            {
                Prefix = "/custom_blobs/",
                IgnorePrefixCase = true,
                ConnectionString = "UseDevelopmentStorage=true;",
                // Only allow 'my_container' to be accessed. /custom_blobs/my_container/key.jpg would be an example path.
                ContainerKeyFilterFunction = (container, key) =>
                    container == "my_container" ? Tuple.Create(container, key) : null
            });
Lilith River
  • 16,204
  • 2
  • 44
  • 76
  • Perfect! I saw the custom blob service, but must have missed the comment block pointing out how the URL would look. – mfree Jan 20 '21 at 14:38
  • @lilithriver what nuget package has `AddImageflowCustomBlobService()`? The service `AddImageflowAzureBlobService()` compiles fine from I'm guessing `Imageflow.Server.Storage.AzureBlob` but I can't get that other one to be found. – Lavamantis May 03 '21 at 20:04
  • Update: `AddImageflowCustomBlobService()` is not in a Nuget package - you need to get the source code and copy the file `CustomBlobService.cs` into your solution - then it works great. – Lavamantis May 03 '21 at 20:18