[英]Sonata Media CDN Rackspace
I have the next problem with Sonata Media: I'm trying to use the Rackspace CDN for uploading images: My config file looks like this based on current documentation: 我有Sonata Media的下一个问题:我正在尝试使用Rackspace CDN上载图像:根据当前文档,我的配置文件如下所示:
cdn:
server:
path: %cdn_url%
filesystem:
local:
directory: %kernel.root_dir%/../web/uploads/media
create: false
rackspace:
url: %rackspace.opencloud.host%
secret:
username: %rackspace.opencloud.username%
apiKey: %rackspace.opencloud.api_key%
region: LON
containerName: projectName
create_container: false
replicate:
master: sonata.media.adapter.filesystem.opencloud
slave: sonata.media.adapter.filesystem.local
And on providers config: 并在提供者配置上:
providers:
image:
filesystem: sonata.media.filesystem.replicate
cdn: sonata.media.cdn.server
resizer: sonata.media.resizer.square
allowed_extensions: ['jpg', 'png', 'gif', 'jpeg']
allowed_mime_types: ['image/pjpeg','image/jpeg','image/png','image/x-png', 'image/gif']
The problem is(how I discovered this bug)if Rackspace is down or incorrect username/password are provided on every page of the app I'm getting this answer: 问题是(我如何发现此错误)如果Rackspace关闭或在应用程序的每个页面上提供了错误的用户名/密码,我都会得到以下答案:
Client error response [status code] 401 [reason phrase] Unauthorized [url] https://lon.auth.api.rackspacecloud.com/v2.0/tokens
This is because Gaufrette Opencloud tries to create a connection on Kernel load. 这是因为Gaufrette Opencloud尝试在内核负载上创建连接。
The quickest solution as a temporary fix was to create a compiler pass and check if the authenticate method returns false then replace argument 0 for replicate definition with the local filesystem adaptor. 临时修复的最快解决方案是创建编译器遍历,并检查authenticate方法是否返回false,然后使用本地文件系统适配器替换复制定义的参数0。
My questions are: 我的问题是:
Thank you in advance and please in case there are not sufficient information provided please leave a comment. 预先谢谢您,如果没有足够的信息,请发表评论。
Apparently there is a solution for lazy loading implemented in Gaufrette: https://github.com/KnpLabs/KnpGaufretteBundle/issues/72 显然,在Gaufrette中实现了一种用于延迟加载的解决方案: https : //github.com/KnpLabs/KnpGaufretteBundle/issues/72
All I had to do is: 我要做的就是:
sonata.media.adapter.open_stack:
class: OpenCloud\Rackspace
arguments: [ %rackspace.opencloud.host%, { username: %rackspace.opencloud.username%, apiKey: %rackspace.opencloud.api_key% }]
sonata.media.adapter.object_store_factory:
class: Gaufrette\Adapter\OpenStackCloudFiles\ObjectStoreFactory
arguments: [ @sonata.media.adapter.open_stack, "LON", ""]
sonata.media.adapter.filesystem.lazyopencloud:
class: Gaufrette\Adapter\LazyOpenCloud
arguments: [ @sonata.media.adapter.object_store_factory, %rackspace.opencloud.container_name%]
And change replicate master to sonata.media.adapter.filesystem.lazyopencloud 并将复制母版更改为sonata.media.adapter.filesystem.lazyopencloud
Hope it helps :) 希望能帮助到你 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.