2014-09-26 126 views
2

我无法让LiipImagineBundle识别流路径。它不是加载图像并应用指定的过滤器集,而是将流路径视为正常的网络路径。Symfony2:使用LiipImagineBundle和KnpGaufretteBundle以及Amazon S3中的树枝模板

这是我可以从各种来源拼凑起来的配置。我无法准确找到任何解决此问题的方法。就LiipImagineBundle而言,这些设置似乎没有取得任何成就。没有错误或警告,并且日志中没有任何内容。它完全忽略了我的配置。

#/src/Acme/StorageBundle/Resources/config/services.yml 
services: 
    acme_storage.amazon_s3: 
    class:  %acme_storage.amazon_s3.class% 
    arguments: 
     options: 
     key:  %acme_storage.amazon_s3.aws_key% 
     secret: %acme_storage.amazon_s3.aws_secret_key% 
     certificate_authority: true 

    liip_imagine.binary.loader.stream.amazon_s3: 
    class: %liip_imagine.binary.loader.stream.class% 
    arguments: 
     - @liip_imagine 
     - 'gaufrette://amazon_s3/' 
    tags: 
     - name: liip_imagine.binary.loader 
     loader: stream.amazon_s3 

    liip_imagine.cache.resolver.amazon_s3: 
    class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver 
    arguments: 
     - @acme_storage.amazon_s3 
     - %amazon_s3_bucket_name% 
    tags: 
     - name: liip_imagine.cache.resolver 
     resolver: cache.amazon_s3 

# /app/config/config.yml 
knp_gaufrette: 
    stream_wrapper: 
    protocol:  gaufrette 
    filesystems: 
     amazon_s3: photo_storage 
    adapters: 
    photo_storage: 
     amazon_s3: 
     amazon_s3_id: beebop_storage.amazon_s3 
     bucket_name: %amazon_s3_bucket_name% 
     create:  false 
     options: 
      create:  true 
      region:  %amazon_s3_region% 
    filesystems: 
    photo_storage: 
     adapter:  photo_storage 
     alias:   photo_storage_filesystem 

liip_imagine: 
    cache:    cache.amazon_s3 
    loaders: 
    stream.amazon_s3: 
     stream: 
     wrapper:  gaufrette://amazon_s3 

    filter_sets: 
    cache: ~ 
    event_small: 
     data_loader: stream.amazon_s3 
     quality:  75 
     filters: 
     thumbnail: 
      size:  [60, 60] 
      mode:  outbound 
      allow_upscale: true 

嫩枝:

{{ 'gaufrette://amazon_s3/file.jpg'|imagine_filter('event_small') }} 

产地:

http://example.com/media/cache/resolve/event_small/gaufrette://amazon_s3/file.jpg 

回答

0

我就是这样做的星期前,但我没有使用S3的缓存。你的问题似乎与形象路径有关。试试这个枝杈上:

{{ 'file.jpg'|imagine_filter('event_small') }} 

由于您的数据加载器知道你所使用的流缓存解析器知道该文件位于URL,那么你只需要通过文件名。

,从你的配置不同矿山,另一件事是,我的有gaufrette路径上的领先/

liip_imagine: 
    loaders: 
    stream.amazon_s3: 
     stream: 
     wrapper:  gaufrette://amazon_s3/ 

希望它可以帮助。

+0

不幸的是,在应用这些更改后,LiipImagineBundle的行为保持不变。它只是将我传递给'imagine_filter()'的任何东西都预取到它的本地缓存路径。 – turibe 2014-09-26 19:50:47

+0

当您在浏览器上打开'http:// example.com/media/cache/resolve/event_small/file.jpg'时,是否出现错误?此路径应该将您重定向到缓存文件。 – lsouza 2014-09-27 01:54:20

+0

是的,我得到一个500内部服务器错误:“给定的上下文不是有效的资源,”发生在'Liip \ ImagineBundle \ Binary \ Loader \ StreamLoader'中。我可以通过更深入地了解该位置正在发生的事情来弄清楚。 – turibe 2014-09-27 02:47:08