【问题标题】:Using ImageFlow Server with multiple Azure Containers将 ImageFlow 服务器与多个 Azure 容器一起使用
【发布时间】:2021-01-20 12:58:36
【问题描述】:

我目前正在评估 ImageFlow Server (https://github.com/imazen/imageflow-dotnet-server) 以确定它是否能够满足我正在从事的项目的需求。通过文档,我能够使用以下方法将 ImageFlow 服务器连接到 Azure 存储:

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

这没有问题,我可以看到预期的图像。该项目的当前要求要求每个用户都有一个唯一的容器,这使得上述实现变得不可能。

有没有办法在发出请求时将容器名称与文件名一起传递?类似于:'/azure/CONTAINER/image.jpg?w=250'

【问题讨论】:

    标签: imageresizer imageflow


    【解决方案1】:

    我们在这里有一个示例提供者可以做到这一点: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
                });
    

    【讨论】:

    • 完美!我看到了自定义 blob 服务,但一定错过了指出 URL 外观的注释块。
    • @lilithriver 什么 nuget 包有 AddImageflowCustomBlobService()?服务 AddImageflowAzureBlobService() 编译得很好,我猜 Imageflow.Server.Storage.AzureBlob 但我找不到另一个。
    • 更新:AddImageflowCustomBlobService() 不在 Nuget 包中 - 您需要获取源代码并将文件 CustomBlobService.cs 复制到您的解决方案中 - 然后效果很好。
    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 2017-06-09
    • 2020-04-29
    • 2017-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多