使用ImageFlow服务器与多个Azure容器



我目前正在评估ImageFlow服务器(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'

我们有一个示例提供程序来做这个: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
});

最新更新