跳到内容

链式加载器

编辑此页

The Chain data loader doesn't load the image binary itself; instead it allows for loading the image binary using any number of other configured data loaders. For example, if you configured both a filesystem and flysystem data loader, this loader can be defined to load from both in a defined order, returning the image binary from the first that responds.

提示

此加载器按照它们在链定义中配置的顺序迭代数据加载器,并从第一个支持传递的文件路径的加载器返回图像二进制文件。这意味着如果一个文件存在于多个加载器中,则将使用为此链式加载器在配置文件中定义的第一个加载器返回该文件。

配置

As this loader leverages any number of other configured loaders, its configuration consists only of the list of loaders to try in succession

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# app/config/config.yml

liip_imagine:
    loaders:
        foo:
            filesystem:
                # configure filesystem loader

        bar:
            flysystem:
                # configure flysystem loader

        baz:
            stream:
                # configure stream loader

        qux:
            chain:
                # use the "foo", "bar", and "baz" loaders
                loaders:
                    - foo
                    - bar
                    - baz
这项工作,包括代码示例,根据 Creative Commons BY-SA 3.0 许可获得许可。
目录
    版本