无法使用Gaufrette和Symfony2检查Amazon s3存储桶是否存在

Getting this error when trying to upload a file to my bucket using VichUploader, Gaufrette and the AWS SDK v2 on a Symfony2 web app. Sounds like a problem with the API calls. It's giving me a Denied Access (Error 500 Interal Server Error) Can anybody help me here ?

Config :

knp_gaufrette:
    stream_wrapper: ~

    adapters:
        local_adapter:
            local:
                directory: %kernel.root_dir%/../web/uploads/img
        aws_s3_adapter:
            aws_s3:
                service_id: 'et.aws_s3'
                bucket_name: mybucket
                options:
                    create: false
                    directory: 'uploads'

    filesystems:
        aws_s3_fs:
            adapter:    aws_s3_adapter
        local_fs:
            adapter:    local_adapter

vich_uploader:
    db_driver: orm
    storage: gaufrette
    mappings:
        image:
            uri_prefix: https://s3.amazonaws.com/mybucket # you'll need this set to use the Vich URL generator
            upload_destination: aws_s3_fs
            namer: vich_uploader.namer_uniqid
            delete_on_remove: true
            delete_on_update: true
            inject_on_load:   true

Services :

services:
    et.aws_s3:
        class: Aws\S3\S3Client #Gaufrette\Adapter\AwsS3
        factory_class: Aws\S3\S3Client
        factory_method: factory
        arguments:
            -
                key: key
                secret: key
                region: us-west-2

Stack trace:

[1] Aws\S3\Exception\AccessDeniedException: Access Denied
    at n/a
        in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php line 91

    at Aws\Common\Exception\NamespaceExceptionFactory->createException('Aws\S3\Exception\AccessDeniedException', object(EntityEnclosingRequest), object(Response), array('code' => 'AccessDenied', 'message' => 'Access Denied', 'type' => 'client', 'request_id' => 'B4966F7BBECF30F3', 'parsed' => object(SimpleXMLElement)))
        in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php line 76

    at Aws\Common\Exception\NamespaceExceptionFactory->fromResponse(object(EntityEnclosingRequest), object(Response))
        in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\ExceptionListener.php line 55

    at Aws\Common\Exception\ExceptionListener->onRequestError(object(Event), 'request.error', object(EventDispatcher))
        in  line 

    at call_user_func(array(object(ExceptionListener), 'onRequestError'), object(Event), 'request.error', object(EventDispatcher))
        in C:\xampp2\htdocs\WebProject\app\cache\dev\classes.php line 1790

    at Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(array(array(object(ExceptionListener), 'onRequestError'), array('Guzzle\Http\Message\Request', 'onRequestError')), 'request.error', object(Event))
        in C:\xampp2\htdocs\WebProject\app\cache\dev\classes.php line 1723

    at Symfony\Component\EventDispatcher\EventDispatcher->dispatch('request.error', object(Event))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\Request.php line 589

    at Guzzle\Http\Message\Request->processResponse(array('handle' => object(CurlHandle)))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\Request.php line 378

    at Guzzle\Http\Message\Request->setState('complete', array('handle' => object(CurlHandle)))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\EntityEnclosingRequest.php line 49

    at Guzzle\Http\Message\EntityEnclosingRequest->setState('complete', array('handle' => object(CurlHandle)))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 303

    at Guzzle\Http\Curl\CurlMulti->processResponse(object(EntityEnclosingRequest), object(CurlHandle), array('msg' => '1', 'result' => '0', 'handle' => 'Resource id #2420'))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 257

    at Guzzle\Http\Curl\CurlMulti->processMessages()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 240

    at Guzzle\Http\Curl\CurlMulti->executeHandles()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 224

    at Guzzle\Http\Curl\CurlMulti->perform()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 111

    at Guzzle\Http\Curl\CurlMulti->send()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMultiProxy.php line 94

    at Guzzle\Http\Curl\CurlMultiProxy->send()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Client.php line 284

    at Guzzle\Http\Client->send(object(EntityEnclosingRequest))
        in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Client\AbstractClient.php line 256

    at Aws\Common\Client\AbstractClient->send(object(EntityEnclosingRequest))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Client.php line 136

    at Guzzle\Service\Client->execute(object(S3Command))
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Command\AbstractCommand.php line 153

    at Guzzle\Service\Command\AbstractCommand->execute()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Command\AbstractCommand.php line 189

    at Guzzle\Service\Command\AbstractCommand->getResult()
        in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Client.php line 76

    at Guzzle\Service\Client->__call('CreateBucket', array(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2')))
        in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Client\AbstractClient.php line 104

    at Aws\Common\Client\AbstractClient->__call('createBucket', array(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2')))
        in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 254

    at Aws\S3\S3Client->createBucket(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2'))
        in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 254

    at Gaufrette\Adapter\AwsS3->ensureBucketExists()
        in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 125

    at Gaufrette\Adapter\AwsS3->write('5535ad181397d.png', '')
        in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Filesystem.php line 122

    at Gaufrette\Filesystem->write('5535ad181397d.png', '', true)
        in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Storage\GaufretteStorage.php line 56

    at Vich\UploaderBundle\Storage\GaufretteStorage->doUpload(object(PropertyMapping), object(UploadedFile), '', '5535ad181397d.png')
        in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Storage\AbstractStorage.php line 67

    at Vich\UploaderBundle\Storage\AbstractStorage->upload(object(Image), object(PropertyMapping))
        in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Handler\UploadHandler.php line 64

    at Vich\UploaderBundle\Handler\UploadHandler->upload(object(Image), 'imageFile')
        in C:\xampp2\htdocs\WebProject\app\cache\dev\appDevDebugProjectContainer.php line 9126

    at VichUploaderBundleHandlerUploadHandler_00000000534e394600000000143551d5->upload(object(Image), 'imageFile')
        in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\EventListener\Doctrine\UploadListener.php line 41

    at Vich\UploaderBundle\EventListener\Doctrine\UploadListener->prePersist(object(LifecycleEventArgs))
        in C:\xampp2\htdocs\WebProject\vendor\symfony\symfony\src\Symfony\Bridge\Doctrine\ContainerAwareEventManager.php line 63

    at Symfony\Bridge\Doctrine\ContainerAwareEventManager->dispatchEvent('prePersist', object(LifecycleEventArgs))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\Event\ListenersInvoker.php line 117

    at Doctrine\ORM\Event\ListenersInvoker->invoke(object(ClassMetadata), 'prePersist', object(Image), object(LifecycleEventArgs), '4')
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 896

    at Doctrine\ORM\UnitOfWork->persistNew(object(ClassMetadata), object(Image))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1683

    at Doctrine\ORM\UnitOfWork->doPersist(object(Image), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 2229

    at Doctrine\ORM\UnitOfWork->cascadePersist(object(Event), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1702

    at Doctrine\ORM\UnitOfWork->doPersist(object(Event), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1639

    at Doctrine\ORM\UnitOfWork->persist(object(Event))
        in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php line 579

    at Doctrine\ORM\EntityManager->persist(object(Event))
        in C:\xampp2\htdocs\WebProject\src\ET\CoreBundle\Controller\EventController.php line 63

    at ET\CoreBundle\Controller\EventController->createAction(object(Request))
        in  line 

    at call_user_func_array(array(object(EventController), 'createAction'), array(object(Request)))
        in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 3029

    at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
        in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 2991

    at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
        in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 3140

    at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
        in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 2384

    at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
        in C:\xampp2\htdocs\WebProject\web\app_dev.php line 28
dony113407
dony113407 您是否已将S3存储桶的许可授予您的IP或网络服务器?S3最初会阻止所有外部访问,您需要应用存储桶策略。最简单的方法是授予您的Web服务器访问权限,并仅通过Web服务器访问S3,以便您可以控制执行请求的人员。
大约 5 年之前 回复

1个回答



原来我的存储区域错误。 我以为我是在us-west-2中创建的,但显然它没有设置区域。</ p>

更改:</ p>

region :us-west-2 </ code> </ p>

To </ p>

region:〜</ code> </ p>
< / DIV>

展开原文

原文

Turns out my bucket region was wrong. I thought I had created it in us-west-2 but apparently it had no region set to it.

Changed:

region: us-west-2

To

region: ~

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

在Amazon S3中上传图像

<div class="post-text" itemprop="text"> <p>I tried to upload an image in s3 using this tutorial <a href="https://florian.ec/articles/upload-files-to-amazon-s3-with-symfony2-and-gaufrette/" rel="nofollow noreferrer">https://florian.ec/articles/upload-files-to-amazon-s3-with-symfony2-and-gaufrette/</a> but I get the error: "The localhost page isn’t working" when I access this function : $uploader = $this-&gt;get('kdm_storage.photo_uploader'); </p> <pre><code> $uploader = $this-&gt;get('kdm_storage.photo_uploader'); $uploadedUrl = $uploader-&gt;upload($logo); $t = $this-&gt;container-&gt;getParameter('amazon_s3_base_url') . $uploadedUrl; </code></pre> <p>services.xml</p> <pre><code> &lt;parameters&gt; &lt;parameter key="kdm_storage.photo_uploader.class"&gt;KDK\Controller\PhotoUploader&lt;/parameter&gt; &lt;/parameters&gt; &lt;services&gt; &lt;service id="kdm_storage.photo_uploader" class="%kdm_storage.photo_uploader.class%"&gt; &lt;argument type="service" id="photo_storage_filesystem" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre> <p>config.yml </p> <pre><code>knp_gaufrette: adapters: photo_storage: amazon_s3: amazon_s3_id: kdm_storage.amazon_s3 bucket_name: %amazon_s3_bucket_name% create: false options: create: true filesystems: photo_storage: adapter: photo_storage alias: photo_storage_filesystem </code></pre> </div>

app / console assets:使用流包装器错误安装到S3

<div class="post-text" itemprop="text"> <p>I have a stream wrapper configured to work with amazon s3 using the <a href="https://github.com/KnpLabs/KnpGaufretteBundle" rel="nofollow">Gaufrette</a> bundle to manage the filesystem. I can successfully dump assets using assetic and my current configuration is as follows:</p> <pre><code>knp_gaufrette: adapters: amazon: amazon_s3: amazon_s3_id: site_store.s3 bucket_name: %site_store.bucket_name% create: true filesystems: amazon: adapter: amazon stream_wrapper: protocol: s3 filesystems: - amazon assetic: read_from: %cdn_path_prod% write_to: %cdn_path_prod% </code></pre> <p>and my params:</p> <pre><code> cdn_url_prod: "http://images.site.com/" cdn_path_prod: "s3://amazon" </code></pre> <p>I was able to do app/console assetic:dump --env=dev. Then it would upload the assets to my s3 buckets successfully. However when I try to do the same with assets install by doing:</p> <pre><code>app/console assets:install s3://amazon </code></pre> <p>It gives me this error:</p> <pre><code>[InvalidArgumentException] The specified path (s3://amazon) is invalid. </code></pre> <p>I've looked over the web and someone was able to do it as he described <a href="https://github.com/symfony/symfony/issues/4014" rel="nofollow">here</a>. What is wrong with my steam wrapper?</p> </div>

Symfony Gaufrette - 从文件系统下载或读取图像并以树枝形式显示

<div class="post-text" itemprop="text"> <p>my question is simple. I use Symfony framework and Gaufrette filesystem (KnpGaufretteBundle) and I allready saved files (images) in filesystem.</p> <p>Now I want show that images in twig. In controller I get the file:</p> <pre><code>$image = $filesystem-&gt;get($fie_key); </code></pre> <p>In variable $image is <strong>Gaufrette\File</strong> object. I would like to display that image in twig in <code>&lt;img&gt;</code> tag. But i don't know how to do that. Thank you for help</p> </div>

在Symfony2中使用带有KnpGaufrette和Doctrine的VichUploader时的循环引用

<div class="post-text" itemprop="text"> <p>I tried to use the following setup in my Symfony2 project:</p> <ul> <li><a href="https://github.com/dustin10/VichUploaderBundle" rel="nofollow">VichUploader Bundle</a> for handling file uploads</li> <li><a href="https://github.com/KnpLabs/KnpGaufretteBundle" rel="nofollow">KnpGaufrette Bundle</a> which should be used by VichUploader as a storage adapter</li> </ul> <p><strong>Problem:</strong> As soon as i try to use the Gaufrette storage adapter "doctrine_dbal" I get the following error:</p> <pre><code>[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException] Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.orm.default_entity_manager -&gt; doctrine.dbal.default_connection -&gt; vich_uploader.upload_handler -&gt; vich_uploader.storage.gaufrette -&gt; knp_gaufrette.filesystem_map -&gt; gaufrette.storage_fs_filesystem". </code></pre> <p>The problem occurs as soon as Symfony tries to check the configuration, e.g. on </p> <pre><code>app/console cache:clear </code></pre> <p>How can I resolve this issue?</p> <h1>My Setup</h1> <p>My project setup is the default setup of <code>symfony/framework-standard-edition</code> with version <code>2.5.*</code> without AcmeDemo Bundle.</p> <p>I simply did add the Bundles via Composer:</p> <pre><code>composer require knplabs/knp-gaufrette-bundle vich/uploader-bundle </code></pre> <p>... added them to AppKernel's <code>registerBundles()</code>:</p> <pre><code>//... $bundles = array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new AppBundle\AppBundle(), new Vich\UploaderBundle\VichUploaderBundle(), //NEW new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(), //NEW ); //... </code></pre> <p>... and added the following configuration to <code>config.yml</code>, which is based on the docs <a href="https://github.com/dustin10/VichUploaderBundle/blob/v0.14.0/Resources/doc/storage/gaufrette.md#configuration" rel="nofollow">VichUploader with Gaufrette</a> and <a href="https://github.com/KnpLabs/KnpGaufretteBundle/blob/v0.1.7/README.markdown#doctrine-dbal-doctrine_dbal" rel="nofollow">KnpGaufrette with Doctrine DBAL</a>:</p> <pre><code># ... knp_gaufrette: stream_wrapper: ~ adapters: storage_adapter: doctrine_dbal: connection_name: default table: data_storage columns: key: id content: file mtime: mtime checksum: checksum filesystems: storage_fs: adapter: storage_adapter vich_uploader: db_driver: orm storage: gaufrette mappings: storage: uri_prefix: /images/products upload_destination: storage_fs </code></pre> </div>

上传大文件停在1GB gaufrette phpseclinb

<div class="post-text" itemprop="text"> <p>I'm trying simple copy files between server sftp using gaufrette and phpseclib. Local adapter server no problem sends more than 1GB. If i am trying send remote always stops at 1GB logs look like</p> <pre><code> 00000fe0 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 ................ 00000ff0 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 ................ 00001000 00:00:00:00:00:00:00:00 ........ &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0001, network: 0s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0009, network: 0.0008s) 00000000 00:00:01:00:00:00:00:1c:00:00:00:18:65:00:00:00 ............e... 00000010 01:00:00:00:00:00:00:00:07:53:75:63:63:65:73:73 .........Success 00000020 00:00:00:00 .... &lt;- NET_SSH2_MSG_KEXINIT (since last: 0.0001, network: 0s) 00000000 d3:0d:5e:69:3d:0d:7f:e8:13:a6:fd:85:f6:05:3c:02 ..^i=........... 00000010 00:00:00:d4:63:75:72:76:65:32:35:35:31:39:2d:73 ....curve25519-s 00000020 68:61:32:35:36:40:6c:69:62:73:73:68:2e:6f:72:67 ha256@libssh.org 00000030 2c:65:63:64:68:2d:73:68:61:32:2d:6e:69:73:74:70 ,ecdh-sha2-nistp 00000040 32:35:36:2c:65:63:64:68:2d:73:68:61:32:2d:6e:69 256,ecdh-sha2-ni 00000050 73:74:70:33:38:34:2c:65:63:64:68:2d:73:68:61:32 stp384,ecdh-sha2 00000060 2d:6e:69:73:74:70:35:32:31:2c:64:69:66:66:69:65 -nistp521,diffie 00000070 2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d:65 -hellman-group-e 00000080 78:63:68:61:6e:67:65:2d:73:68:61:32:35:36:2c:64 xchange-sha256,d 00000090 69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72 iffie-hellman-gr 000000a0 6f:75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61 oup-exchange-sha 000000b0 31:2c:64:69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e 1,diffie-hellman 000000c0 2d:67:72:6f:75:70:31:34:2d:73:68:61:31:2c:64:69 -group14-sha1,di 000000d0 66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f ffie-hellman-gro 000000e0 75:70:31:2d:73:68:61:31:00:00:00:27:73:73:68:2d up1-sha1...'ssh- 000000f0 72:73:61:2c:65:63:64:73:61:2d:73:68:61:32:2d:6e rsa,ecdsa-sha2-n 00000100 69:73:74:70:32:35:36:2c:73:73:68:2d:65:64:32:35 istp256,ssh-ed25 00000110 35:31:39:00:00:00:e9:61:65:73:31:32:38:2d:63:74 519....aes128-ct 00000120 72:2c:61:65:73:31:39:32:2d:63:74:72:2c:61:65:73 r,aes192-ctr,aes 00000130 32:35:36:2d:63:74:72:2c:61:72:63:66:6f:75:72:32 256-ctr,arcfour2 00000140 35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c:61:65 56,arcfour128,ae 00000150 73:31:32:38:2d:67:63:6d:40:6f:70:65:6e:73:73:68 s128-gcm@openssh 00000160 2e:63:6f:6d:2c:61:65:73:32:35:36:2d:67:63:6d:40 .com,aes256-gcm@ 00000170 6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:63:68:61:63 openssh.com,chac 00000180 68:61:32:30:2d:70:6f:6c:79:31:33:30:35:40:6f:70 ha20-poly1305@op 00000190 65:6e:73:73:68:2e:63:6f:6d:2c:61:65:73:31:32:38 enssh.com,aes128 000001a0 2d:63:62:63:2c:33:64:65:73:2d:63:62:63:2c:62:6c -cbc,3des-cbc,bl 000001b0 6f:77:66:69:73:68:2d:63:62:63:2c:63:61:73:74:31 owfish-cbc,cast1 000001c0 32:38:2d:63:62:63:2c:61:65:73:31:39:32:2d:63:62 28-cbc,aes192-cb 000001d0 63:2c:61:65:73:32:35:36:2d:63:62:63:2c:61:72:63 c,aes256-cbc,arc 000001e0 66:6f:75:72:2c:72:69:6a:6e:64:61:65:6c:2d:63:62 four,rijndael-cb 000001f0 63:40:6c:79:73:61:74:6f:72:2e:6c:69:75:2e:73:65 c@lysator.liu.se 00000200 00:00:00:e9:61:65:73:31:32:38:2d:63:74:72:2c:61 ....aes128-ctr,a 00000210 65:73:31:39:32:2d:63:74:72:2c:61:65:73:32:35:36 es192-ctr,aes256 00000220 2d:63:74:72:2c:61:72:63:66:6f:75:72:32:35:36:2c -ctr,arcfour256, 00000230 61:72:63:66:6f:75:72:31:32:38:2c:61:65:73:31:32 arcfour128,aes12 00000240 38:2d:67:63:6d:40:6f:70:65:6e:73:73:68:2e:63:6f 8-gcm@openssh.co 00000250 6d:2c:61:65:73:32:35:36:2d:67:63:6d:40:6f:70:65 m,aes256-gcm@ope 00000260 6e:73:73:68:2e:63:6f:6d:2c:63:68:61:63:68:61:32 nssh.com,chacha2 00000270 30:2d:70:6f:6c:79:31:33:30:35:40:6f:70:65:6e:73 0-poly1305@opens 00000280 73:68:2e:63:6f:6d:2c:61:65:73:31:32:38:2d:63:62 sh.com,aes128-cb 00000290 63:2c:33:64:65:73:2d:63:62:63:2c:62:6c:6f:77:66 c,3des-cbc,blowf 000002a0 69:73:68:2d:63:62:63:2c:63:61:73:74:31:32:38:2d ish-cbc,cast128- 000002b0 63:62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c:61 cbc,aes192-cbc,a 000002c0 65:73:32:35:36:2d:63:62:63:2c:61:72:63:66:6f:75 es256-cbc,arcfou 000002d0 72:2c:72:69:6a:6e:64:61:65:6c:2d:63:62:63:40:6c r,rijndael-cbc@l 000002e0 79:73:61:74:6f:72:2e:6c:69:75:2e:73:65:00:00:01 ysator.liu.se... 000002f0 92:68:6d:61:63:2d:6d:64:35:2d:65:74:6d:40:6f:70 .hmac-md5-etm@op 00000300 65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73 enssh.com,hmac-s 00000310 68:61:31:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e ha1-etm@openssh. 00000320 63:6f:6d:2c:75:6d:61:63:2d:36:34:2d:65:74:6d:40 com,umac-64-etm@ 00000330 6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63 openssh.com,umac 00000340 2d:31:32:38:2d:65:74:6d:40:6f:70:65:6e:73:73:68 -128-etm@openssh 00000350 2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:32 .com,hmac-sha2-2 00000360 35:36:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63 56-etm@openssh.c 00000370 6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32 om,hmac-sha2-512 00000380 2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d -etm@openssh.com 00000390 2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:2d ,hmac-ripemd160- 000003a0 65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c etm@openssh.com, 000003b0 68:6d:61:63:2d:73:68:61:31:2d:39:36:2d:65:74:6d hmac-sha1-96-etm 000003c0 40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61 @openssh.com,hma 000003d0 63:2d:6d:64:35:2d:39:36:2d:65:74:6d:40:6f:70:65 c-md5-96-etm@ope 000003e0 6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:6d:64 nssh.com,hmac-md 000003f0 35:2c:68:6d:61:63:2d:73:68:61:31:2c:75:6d:61:63 5,hmac-sha1,umac 00000400 2d:36:34:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c -64@openssh.com, 00000410 75:6d:61:63:2d:31:32:38:40:6f:70:65:6e:73:73:68 umac-128@openssh 00000420 2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:32:2d:32 .com,hmac-sha2-2 00000430 35:36:2c:68:6d:61:63:2d:73:68:61:32:2d:35:31:32 56,hmac-sha2-512 00000440 2c:68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:2c ,hmac-ripemd160, 00000450 68:6d:61:63:2d:72:69:70:65:6d:64:31:36:30:40:6f hmac-ripemd160@o 00000460 70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d penssh.com,hmac- 00000470 73:68:61:31:2d:39:36:2c:68:6d:61:63:2d:6d:64:35 sha1-96,hmac-md5 00000480 2d:39:36:00:00:01:92:68:6d:61:63:2d:6d:64:35:2d -96....hmac-md5- 00000490 65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c etm@openssh.com, 000004a0 68:6d:61:63:2d:73:68:61:31:2d:65:74:6d:40:6f:70 hmac-sha1-etm@op 000004b0 65:6e:73:73:68:2e:63:6f:6d:2c:75:6d:61:63:2d:36 enssh.com,umac-6 000004c0 34:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f 4-etm@openssh.co 000004d0 6d:2c:75:6d:61:63:2d:31:32:38:2d:65:74:6d:40:6f m,umac-128-etm@o 000004e0 70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d penssh.com,hmac- 000004f0 73:68:61:32:2d:32:35:36:2d:65:74:6d:40:6f:70:65 sha2-256-etm@ope 00000500 6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68 nssh.com,hmac-sh 00000510 61:32:2d:35:31:32:2d:65:74:6d:40:6f:70:65:6e:73 a2-512-etm@opens 00000520 73:68:2e:63:6f:6d:2c:68:6d:61:63:2d:72:69:70:65 sh.com,hmac-ripe 00000530 6d:64:31:36:30:2d:65:74:6d:40:6f:70:65:6e:73:73 md160-etm@openss 00000540 68:2e:63:6f:6d:2c:68:6d:61:63:2d:73:68:61:31:2d h.com,hmac-sha1- 00000550 39:36:2d:65:74:6d:40:6f:70:65:6e:73:73:68:2e:63 96-etm@openssh.c 00000560 6f:6d:2c:68:6d:61:63:2d:6d:64:35:2d:39:36:2d:65 om,hmac-md5-96-e 00000570 74:6d:40:6f:70:65:6e:73:73:68:2e:63:6f:6d:2c:68 tm@openssh.com,h 00000580 6d:61:63:2d:6d:64:35:2c:68:6d:61:63:2d:73:68:61 mac-md5,hmac-sha 00000590 31:2c:75:6d:61:63:2d:36:34:40:6f:70:65:6e:73:73 1,umac-64@openss 000005a0 68:2e:63:6f:6d:2c:75:6d:61:63:2d:31:32:38:40:6f h.com,umac-128@o 000005b0 70:65:6e:73:73:68:2e:63:6f:6d:2c:68:6d:61:63:2d penssh.com,hmac- 000005c0 73:68:61:32:2d:32:35:36:2c:68:6d:61:63:2d:73:68 sha2-256,hmac-sh 000005d0 61:32:2d:35:31:32:2c:68:6d:61:63:2d:72:69:70:65 a2-512,hmac-ripe 000005e0 6d:64:31:36:30:2c:68:6d:61:63:2d:72:69:70:65:6d md160,hmac-ripem 000005f0 64:31:36:30:40:6f:70:65:6e:73:73:68:2e:63:6f:6d d160@openssh.com 00000600 2c:68:6d:61:63:2d:73:68:61:31:2d:39:36:2c:68:6d ,hmac-sha1-96,hm 00000610 61:63:2d:6d:64:35:2d:39:36:00:00:00:15:6e:6f:6e ac-md5-96....non 00000620 65:2c:7a:6c:69:62:40:6f:70:65:6e:73:73:68:2e:63 e,zlib@openssh.c 00000630 6f:6d:00:00:00:15:6e:6f:6e:65:2c:7a:6c:69:62:40 om....none,zlib@ 00000640 6f:70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:00:00 openssh.com..... 00000650 00:00:00:00:00:00:00:00 ........ -&gt; NET_SSH2_MSG_KEXINIT (since last: 0.0001, network: 0s) 00000000 e0:dc:b7:cf:3a:4a:e8:be:96:1e:ec:59:03:39:8e:8e ....:J.....Y.9.. 00000010 00:00:00:7e:64:69:66:66:69:65:2d:68:65:6c:6c:6d ...~diffie-hellm 00000020 61:6e:2d:67:72:6f:75:70:31:2d:73:68:61:31:2c:64 an-group1-sha1,d 00000030 69:66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72 iffie-hellman-gr 00000040 6f:75:70:31:34:2d:73:68:61:31:2c:64:69:66:66:69 oup14-sha1,diffi 00000050 65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f:75:70:2d e-hellman-group- 00000060 65:78:63:68:61:6e:67:65:2d:73:68:61:31:2c:64:69 exchange-sha1,di 00000070 66:66:69:65:2d:68:65:6c:6c:6d:61:6e:2d:67:72:6f ffie-hellman-gro 00000080 75:70:2d:65:78:63:68:61:6e:67:65:2d:73:68:61:32 up-exchange-sha2 00000090 35:36:00:00:00:0f:73:73:68:2d:72:73:61:2c:73:73 56....ssh-rsa,ss 000000a0 68:2d:64:73:73:00:00:00:e9:61:72:63:66:6f:75:72 h-dss....arcfour 000000b0 32:35:36:2c:61:72:63:66:6f:75:72:31:32:38:2c:61 256,arcfour128,a 000000c0 65:73:31:32:38:2d:63:74:72:2c:61:65:73:31:39:32 es128-ctr,aes192 000000d0 2d:63:74:72:2c:61:65:73:32:35:36:2d:63:74:72:2c -ctr,aes256-ctr, 000000e0 74:77:6f:66:69:73:68:31:32:38:2d:63:74:72:2c:74 twofish128-ctr,t 000000f0 77:6f:66:69:73:68:31:39:32:2d:63:74:72:2c:74:77 wofish192-ctr,tw 00000100 6f:66:69:73:68:32:35:36:2d:63:74:72:2c:61:65:73 ofish256-ctr,aes 00000110 31:32:38:2d:63:62:63:2c:61:65:73:31:39:32:2d:63 128-cbc,aes192-c 00000120 62:63:2c:61:65:73:32:35:36:2d:63:62:63:2c:74:77 bc,aes256-cbc,tw 00000130 6f:66:69:73:68:31:32:38:2d:63:62:63:2c:74:77:6f ofish128-cbc,two 00000140 66:69:73:68:31:39:32:2d:63:62:63:2c:74:77:6f:66 fish192-cbc,twof 00000150 69:73:68:32:35:36:2d:63:62:63:2c:74:77:6f:66:69 ish256-cbc,twofi 00000160 73:68:2d:63:62:63:2c:62:6c:6f:77:66:69:73:68:2d sh-cbc,blowfish- 00000170 63:74:72:2c:62:6c:6f:77:66:69:73:68:2d:63:62:63 ctr,blowfish-cbc 00000180 2c:33:64:65:73:2d:63:74:72:2c:33:64:65:73:2d:63 ,3des-ctr,3des-c 00000190 62:63:00:00:00:e9:61:72:63:66:6f:75:72:32:35:36 bc....arcfour256 000001a0 2c:61:72:63:66:6f:75:72:31:32:38:2c:61:65:73:31 ,arcfour128,aes1 000001b0 32:38:2d:63:74:72:2c:61:65:73:31:39:32:2d:63:74 28-ctr,aes192-ct 000001c0 72:2c:61:65:73:32:35:36:2d:63:74:72:2c:74:77:6f r,aes256-ctr,two 000001d0 66:69:73:68:31:32:38:2d:63:74:72:2c:74:77:6f:66 fish128-ctr,twof 000001e0 69:73:68:31:39:32:2d:63:74:72:2c:74:77:6f:66:69 ish192-ctr,twofi 000001f0 73:68:32:35:36:2d:63:74:72:2c:61:65:73:31:32:38 sh256-ctr,aes128 00000200 2d:63:62:63:2c:61:65:73:31:39:32:2d:63:62:63:2c -cbc,aes192-cbc, 00000210 61:65:73:32:35:36:2d:63:62:63:2c:74:77:6f:66:69 aes256-cbc,twofi 00000220 73:68:31:32:38:2d:63:62:63:2c:74:77:6f:66:69:73 sh128-cbc,twofis 00000230 68:31:39:32:2d:63:62:63:2c:74:77:6f:66:69:73:68 h192-cbc,twofish 00000240 32:35:36:2d:63:62:63:2c:74:77:6f:66:69:73:68:2d 256-cbc,twofish- 00000250 63:62:63:2c:62:6c:6f:77:66:69:73:68:2d:63:74:72 cbc,blowfish-ctr 00000260 2c:62:6c:6f:77:66:69:73:68:2d:63:62:63:2c:33:64 ,blowfish-cbc,3d 00000270 65:73:2d:63:74:72:2c:33:64:65:73:2d:63:62:63:00 es-ctr,3des-cbc. 00000280 00:00:39:68:6d:61:63:2d:73:68:61:32:2d:32:35:36 ..9hmac-sha2-256 00000290 2c:68:6d:61:63:2d:73:68:61:31:2d:39:36:2c:68:6d ,hmac-sha1-96,hm 000002a0 61:63:2d:73:68:61:31:2c:68:6d:61:63:2d:6d:64:35 ac-sha1,hmac-md5 000002b0 2d:39:36:2c:68:6d:61:63:2d:6d:64:35:00:00:00:39 -96,hmac-md5...9 000002c0 68:6d:61:63:2d:73:68:61:32:2d:32:35:36:2c:68:6d hmac-sha2-256,hm 000002d0 61:63:2d:73:68:61:31:2d:39:36:2c:68:6d:61:63:2d ac-sha1-96,hmac- 000002e0 73:68:61:31:2c:68:6d:61:63:2d:6d:64:35:2d:39:36 sha1,hmac-md5-96 000002f0 2c:68:6d:61:63:2d:6d:64:35:00:00:00:04:6e:6f:6e ,hmac-md5....non 00000300 65:00:00:00:04:6e:6f:6e:65:00:00:00:00:00:00:00 e....none....... 00000310 00:00:00:00:00:00 ...... </code></pre> <p>i've tested connection like filezilla sftp and no problem sends ober 1GB, any idea? Gaufrette looks like have not many options maybe phpseclib?</p> <p>Second though it can be SFTP server problem but if is, i think is should be problem in sending file by filezilla.</p> </div>

ScopeCrossingInjectionException:Symfony2.7

<div class="post-text" itemprop="text"> <p>Everything was working fine on my website, until i decided to add in my composer.json those line:</p> <ul> <li>"avocode/form-extensions-bundle": "dev-master"</li> <li><em>update from dev-master to version:</em> "components/jquery": "2.0",</li> <li>"components/jqueryui": "1.11.4"</li> <li>"component-dir": "web/assets"</li> </ul> <p>After update composer.json i got this error : </p> <p>ScopeCrossingInjectionException in CheckReferenceValidityPass.php line 146: </p> <p>Scope Crossing Injection detected: The definition "sonata.admin.builder.orm_datagrid" references the service "sonata.admin.builder.filter.factory" which belongs to another scope hierarchy. This service might not be available consistently. Generally, it is safer to either move the definition "sonata.admin.builder.orm_datagrid" to scope "prototype", or declare "container" as a child scope of "prototype". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.</p> <p>I tried everything that i could to fix this error but i'm still having it. i deleted all the new line that i added, but still doesn't work.</p> <p>This is my composer.json:</p> <pre><code>{ "name": "symfony/framework-standard-edition", "license": "MIT", "type": "project", "description": "The \"Symfony Standard Edition\" distribution", "autoload": { "psr-0": { "": "src/", "SymfonyStandard": "app/" } }, "minimum-stability": "dev", "require": { "php": "&gt;=5.3.9", "symfony/symfony": "2.7.*", "doctrine/orm": "~2.2,&gt;=2.2.3,&lt;2.5", "doctrine/dbal": "&lt;2.5", "doctrine/doctrine-bundle": "~1.4", "twig/extensions": "~1.0", "symfony/assetic-bundle": "2.6.0", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~3.0,&gt;=3.0.12", "sensio/framework-extra-bundle": "~3.0,&gt;=3.0.2", "incenteev/composer-parameter-handler": "~2.0", "leafo/lessphp": "*", "twitter/bootstrap": "*", "mremi/contact-bundle": "dev-master", "symfony/twig-bridge": "2.3.*", "genemu/form-bundle": "2.2.*", "components/jquery":"dev-master", "friendsofsymfony/user-bundle": "~1.3", "hwi/oauth-bundle": "0.4.*@dev", "knplabs/gaufrette": "~0.1.6", "knplabs/knp-menu-bundle": "~2.0", "sonata-project/user-bundle": "2.3.*@dev", "sonata-project/block-bundle": "~2.3@dev", "sonata-project/admin-bundle": "~2.4@dev", "sonata-project/page-bundle": "~2.3", "sonata-project/datagrid-bundle": "2.2.*@dev", "symfony-cmf/routing-bundle": "~1.1", "sonata-project/core-bundle": "~2.2@dev", "sonata-project/doctrine-orm-admin-bundle": "~2.2", "sonata-project/easy-extends-bundle": "~2.1", "sonata-project/comment-bundle": "~2.2@dev", "sonata-project/ecommerce": "dev-develop", "tetranz/select2entity-bundle": "2.*", "zendframework/zend-crypt" : "dev-master", "cocur/slugify" : "1.4.x-dev", "zenstruck/form-bundle": "dev-master", "stephanecollot/datetimepicker-bundle": "dev-master" }, "require-dev": { "sensio/generator-bundle": "~2.3" }, "scripts": { "post-root-package-install": [ "SymfonyStandard\\Composer::hookRootPackageInstall" ], "post-install-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" ], "post-update-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" ] }, "config": { "bin-dir": "bin" }, "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web", "symfony-assets-install": "relative", "symfony-assets-install":"symlink", "incenteev-parameters": { "file": "app/config/parameters.yml" }, "branch-alias": { "dev-master": "2.7-dev" } } } </code></pre> </div>

如何将来自Burzum / FileStorage的contentType信息传递给KnpLabs / Gaufrette

<div class="post-text" itemprop="text"> <p>CakePHP 3.4 application using the <a href="https://github.com/burzum/cakephp-file-storage" rel="nofollow noreferrer">Burzum/FileStorage</a> plugin (which uses <a href="https://github.com/knplabs/Gaufrette" rel="nofollow noreferrer">KnpLabs/Gaufrette</a>) to manage uploads to AWS S3. Unfortunately, I was running into the issue of MS Office files (docx, xlsx, etc) being detected as ZIP files.</p> <p>I altered my code to use finfo first and if it detects zip, look at the extension to see if it maybe is an office file. Now I can pass this correct mimetype on to the file_storage table by doing a patchEntity. So far so good.</p> <p>However, the FileStorage plugin calls KnpLabs/Gaufrette to actually send the file to S3, but it doesn't seem to send along the mimetype/contenttype. So Gaufrette then does its own little finfo trick in the <a href="https://github.com/KnpLabs/Gaufrette/blob/master/src/Gaufrette/Adapter/AwsS3.php#L166" rel="nofollow noreferrer">AwsS3 Adapter</a>, writing a metadata field 'Content-Type: application/zip' to the item on S3, causing the Office file to be downloaded as a zip file...</p> <p>Is there any way to set the correct content type in the options of the AwsS3 adapter?</p> <p>thanks!</p> </div>

composer安装要求错误,并且无法做作曲家更新

<div class="post-text" itemprop="text"> <p>I'm trying to install <code>KnpMenuBundle</code> here's my current <code>composer.json</code>:</p> <pre><code>{ "name": "symfony/framework-standard-edition", "license": "MIT", "type": "project", "description": "The \"Symfony Standard Edition\" distribution", "autoload": { "psr-0": { "": "src/", "SymfonyStandard": "app/" } }, "require": { "php": "&gt;=5.3.3", "symfony/symfony": "2.5.*", "doctrine/orm": "~2.2,&gt;=2.2.3", "doctrine/doctrine-bundle": "~1.2", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~3.0", "sensio/framework-extra-bundle": "~3.0", "incenteev/composer-parameter-handler": "~2.0", "doctrine/migrations": "dev-master", "doctrine/doctrine-migrations-bundle": "dev-master", "friendsofsymfony/user-bundle": "~2.0@dev", "thrace/form-bundle": "dev-master", "knplabs/knp-menu-bundle": "dev-master", "thrace-project/media-bundle": "dev-master", "knplabs/gaufrette": "dev-master", "knplabs/knp-gaufrette-bundle": "dev-master", "imagine/imagine": "0.5.*" }, "require-dev": { "sensio/generator-bundle": "~2.3" }, "scripts": { "post-root-package-install": [ "SymfonyStandard\\Composer::hookRootPackageInstall" ], "post-install-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" ], "post-update-cmd": [ "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile", "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles" ] }, "config": { "bin-dir": "bin" }, "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web", "incenteev-parameters": { "file": "app/config/parameters.yml" }, "branch-alias": { "dev-master": "2.5-dev" } } } </code></pre> <p>When I try <code>composer install</code>, It gives me this error:</p> <pre><code>Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them. Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for symfony/framework-standard-edition 2.5.x-dev -&gt; satisfiable by symfony/framework-standard-edition[2.5.x-dev]. - symfony/framework-standard-edition 2.5.x-dev requires knplabs/knp-menu-bundle dev-master -&gt; no matching package found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see &lt;https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion&gt; for more details. Read &lt;http://getcomposer.org/doc/articles/troubleshooting.md&gt; for further common problems. </code></pre> <p>I also can't do <code>composer update</code> since it will update my <code>composer.lock</code> and I don't want this to happen. Because I've specified some exact versions to use of <code>ThraceMediaBundle</code> and bundles that it depends on.</p> <p>So i'm stuck with <code>composer install</code> which gives me the above error.</p> <p>Any help would be appreciated.</p> <hr> <p><strong>EDIT</strong></p> <p>When I try:</p> <pre><code>composer update knplabs/knp-menu-bundle:dev-master --dry-run </code></pre> <p>I get this output (I mysteriously removes <code>LiipImagineBundle</code>!)</p> <pre><code>Package "knplabs/knp-menu-bundle:dev-master" listed for update is not installed. Ignoring. Loading composer repositories with package information Updating dependencies (including require-dev) - Uninstalling liip/imagine-bundle (dev-master 4415054) - Installing knplabs/knp-menu (v2.0.1) - Installing knplabs/knp-menu-bundle (dev-master bdfc95d) knplabs/knp-menu suggests installing pimple/pimple (for the built-in implementations of the menu provider and renderer provider) knplabs/knp-menu suggests installing silex/silex (for the integration with your silex application) </code></pre> <hr> <p><strong>EDIT 2</strong></p> <p>My bad, I forgot to add <code>LiipImaginBundle</code> inside composer.json.</p> </div>

Composer更新失败。 可能是google-api-php-client相关

<div class="post-text" itemprop="text"> <p>The following composer.json fails on <strong>composer update</strong>, with the following message:</p> <p>Problem 1 - Installation request for foo/auth-bundle dev-develop -&gt; satisfiable by foo/auth-bundle[dev-develop]. - foo/auth-bundle dev-develop requires google/google-api-php-client 0.6.* -&gt; no matching package found.</p> <pre><code>{ "name": "", "license": "Proprietary", "type": "project", "description": "", "autoload": { "psr-0": { "": "src/" } }, "repositories": [ { "type": "git", "url": "git@github.com:foo/ApiBundle.git" }, { "type": "git", "url": "git@github.com:foo/AuthBundle.git" }, { "type": "git", "url": "git@github.com:foo/ObjectKeyValueMapper.git" }, { "type": "git", "url": "https://github.com/foo/Livefyre-APIs.git" }, { "type": "git", "url": "git@github.com:foo/ImagineExtra.git" }, { "type": "git", "url": "git@github.com:foo/EntityRepositoryBundle.git" }, { "type": "pear", "url": "http://pear.php.net" }, { "type": "pear",at" }, { "type": "package", "package": { "name": "pear-pear.pollinimini.net/Protobuf", "version": "0.9.4", "dist": { "url": "https://s3-eu-west-1.amazonaws.com/test-backend-releases/Protobuf-PHP/Protobuf.zip", "type": "zip" }, "source": { "url": "https://github.com/test/Protobuf-PHP", "type": "git", "reference": "master" }, "autoload": { "classmap": ["/"] } } } ], "require": { "php": "&gt;=5.3.3", "symfony/symfony": "2.3.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.3.*", "symfony/swiftmailer-bundle": "2.3.*", "symfony/monolog-bundle": "2.3.*", "sensio/distribution-bundle": "2.3.*", "sensio/framework-extra-bundle": "2.3.*", "sensio/generator-bundle": "2.3.*", "friendsofsymfony/user-bundle": "2.0.x-dev", "friendsofsymfony/rest-bundle": "0.12.0", "jms/serializer": "*", "jms/serializer-bundle": "0.12.0", "jms/di-extra-bundle": "1.4.0", "monolog/monolog": "1.*", "nelmio/api-doc-bundle": "dev-master", "guzzle/guzzle": "v3.5.0", "snc/redis-bundle": "1.1.5", "predis/predis": "0.8.*@dev", "foo/api-bundle": "dev-develop", "br/signed-request-bundle": "dev-master", "livefyre/api": "dev-master", "basho/riak": "dev-master", "friendsofsymfony/oauth-server-bundle": "1.3.1", "jms/security-extra-bundle": "1.5.1", "amazonwebservices/aws-sdk-for-php": "1.6.2", "knplabs/knp-gaufrette-bundle": "0.2.*@dev", "test/object-key-value-mapper": "dev-develop", "bcc/resque-bundle": "1.1.7", "ocramius/proxy-manager": "0.4.*", "foo/imagine-extra": "dev-master", "ekino/newrelic-bundle": "1.1.0", "foo/auth-bundle": "dev-develop", "foo/entity-repository-bundle": "dev-master", "namshi/jose": "1.1.0", "nelmio/solarium-bundle": "2.0.4", "pear-pear.php.net/Console_CommandLine": "1.2.0" }, "require-dev": { "codeception/codeception": "1.6.4.2" }, "scripts": { "post-install-cmd": [ "fab local_bootstrap", "fab local_cache_clear", "fab local_assets_dump", "fab local_assets_install" ], "post-update-cmd": [ "fab local_bootstrap", "fab local_cache_clear", "fab local_assets_dump", "fab local_assets_install" ] }, "config": { "bin-dir": "bin" }, "minimum-stability": "dev", "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web", "branch-alias": { "dev-master": "2.4-dev" } } } </code></pre> <p>Any guesses?</p> </div>

SonataMediaBundle自定义提供商

<div class="post-text" itemprop="text"> <p>I'm trying to create two custom providers, one for PDF and another one for ZIP files.</p> <p>This is my code.</p> <p><strong>services.yml</strong> </p> <pre><code>parameters: application_sonata_media.zip_class: Application\Sonata\MediaBundle\Provider\ZipProvider services: sonata.media.provider.zip: class: %application_sonata_media.zip_class% tags: - { name: sonata.media.provider } arguments: - sonata.media.provider.zip - @sonata.media.filesystem.local - @sonata.media.cdn.server - @sonata.media.generator.default - @sonata.media.thumbnail.format - ['zip'] - ['application/zip'] </code></pre> <p><strong>sonata_media.yml</strong> </p> <pre><code>sonata_media: contexts: eag_zip: download: strategy: sonata.media.security.public_strategy mode: http providers: - sonata.media.provider.zip formats: reference: { quality: 100 } </code></pre> <p><strong>ZipProvider.php</strong> </p> <pre><code>/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ namespace Application\Sonata\MediaBundle\Provider; use Sonata\MediaBundle\Provider\BaseProvider; use Gaufrette\Filesystem; use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Validator\ErrorElement; use Sonata\CoreBundle\Model\Metadata; use Sonata\MediaBundle\CDN\CDNInterface; use Sonata\MediaBundle\Generator\GeneratorInterface; use Sonata\MediaBundle\Metadata\MetadataBuilderInterface; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Thumbnail\ThumbnailInterface; use Symfony\Component\Form\FormBuilder; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; /** * Description of ZipProvider * * @author Juanjo García &lt;juanjogarcia@editartgroup.com&gt; */ class ZipProvider extends BaseProvider { protected $allowedExtensions; protected $allowedMimeTypes; protected $metadata; /** * @param string $name * @param \Gaufrette\Filesystem $filesystem * @param \Sonata\MediaBundle\CDN\CDNInterface $cdn * @param \Sonata\MediaBundle\Generator\GeneratorInterface $pathGenerator * @param \Sonata\MediaBundle\Thumbnail\ThumbnailInterface $thumbnail * @param array $allowedExtensions * @param array $allowedMimeTypes * @param \Sonata\MediaBundle\Metadata\MetadataBuilderInterface $metadata */ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, GeneratorInterface $pathGenerator, ThumbnailInterface $thumbnail, array $allowedExtensions = array(), array $allowedMimeTypes = array(), MetadataBuilderInterface $metadata = null) { parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail); $this-&gt;allowedExtensions = $allowedExtensions; $this-&gt;allowedMimeTypes = $allowedMimeTypes; $this-&gt;metadata = $metadata; } /** * {@inheritdoc} */ public function getProviderMetadata() { return new Metadata($this-&gt;getName(), $this-&gt;getName().'.description', false, 'SonataMediaBundle', array('class' =&gt; 'fa fa-file-text-o')); } /** * {@inheritdoc} */ public function getReferenceImage(MediaInterface $media) { return sprintf('%s/%s', $this-&gt;generatePath($media), $media-&gt;getProviderReference() ); } /** * {@inheritdoc} */ public function getReferenceFile(MediaInterface $media) { return $this-&gt;getFilesystem()-&gt;get($this-&gt;getReferenceImage($media), true); } /** * {@inheritdoc} */ public function buildEditForm(FormMapper $formMapper) { $formMapper-&gt;add('name'); $formMapper-&gt;add('enabled', null, array('required' =&gt; false)); $formMapper-&gt;add('authorName'); $formMapper-&gt;add('cdnIsFlushable'); $formMapper-&gt;add('description'); $formMapper-&gt;add('copyright'); $formMapper-&gt;add('binaryContent', 'file', array('required' =&gt; false)); } /** * {@inheritdoc} */ public function buildCreateForm(FormMapper $formMapper) { $formMapper-&gt;add('binaryContent', 'file', array( 'constraints' =&gt; array( new NotBlank(), new NotNull(), ), )); } /** * {@inheritdoc} */ public function buildMediaType(FormBuilder $formBuilder) { $formBuilder-&gt;add('binaryContent', 'file'); } /** * {@inheritdoc} */ public function postPersist(MediaInterface $media) { if ($media-&gt;getBinaryContent() === null) { return; } $this-&gt;setFileContents($media); $this-&gt;generateThumbnails($media); } /** * {@inheritdoc} */ public function postUpdate(MediaInterface $media) { if (!$media-&gt;getBinaryContent() instanceof \SplFileInfo) { return; } // Delete the current file from the FS $oldMedia = clone $media; $oldMedia-&gt;setProviderReference($media-&gt;getPreviousProviderReference()); $path = $this-&gt;getReferenceImage($oldMedia); if ($this-&gt;getFilesystem()-&gt;has($path)) { $this-&gt;getFilesystem()-&gt;delete($path); } $this-&gt;fixBinaryContent($media); $this-&gt;setFileContents($media); $this-&gt;generateThumbnails($media); } /** * @throws \RuntimeException * * @param \Sonata\MediaBundle\Model\MediaInterface $media * * @return */ protected function fixBinaryContent(MediaInterface $media) { if ($media-&gt;getBinaryContent() === null) { return; } // if the binary content is a filename =&gt; convert to a valid File if (!$media-&gt;getBinaryContent() instanceof File) { if (!is_file($media-&gt;getBinaryContent())) { throw new \RuntimeException('The file does not exist : '.$media-&gt;getBinaryContent()); } $binaryContent = new File($media-&gt;getBinaryContent()); $media-&gt;setBinaryContent($binaryContent); } } /** * @throws \RuntimeException * * @param \Sonata\MediaBundle\Model\MediaInterface $media */ protected function fixFilename(MediaInterface $media) { if ($media-&gt;getBinaryContent() instanceof UploadedFile) { $media-&gt;setName($media-&gt;getName() ?: $media-&gt;getBinaryContent()-&gt;getClientOriginalName()); $media-&gt;setMetadataValue('filename', $media-&gt;getBinaryContent()-&gt;getClientOriginalName()); } elseif ($media-&gt;getBinaryContent() instanceof File) { $media-&gt;setName($media-&gt;getName() ?: $media-&gt;getBinaryContent()-&gt;getBasename()); $media-&gt;setMetadataValue('filename', $media-&gt;getBinaryContent()-&gt;getBasename()); } // this is the original name if (!$media-&gt;getName()) { throw new \RuntimeException('Please define a valid media\'s name'); } } /** * {@inheritdoc} */ protected function doTransform(MediaInterface $media) { $this-&gt;fixBinaryContent($media); $this-&gt;fixFilename($media); // this is the name used to store the file if (!$media-&gt;getProviderReference()) { $media-&gt;setProviderReference($this-&gt;generateReferenceName($media)); } if ($media-&gt;getBinaryContent()) { $media-&gt;setContentType($media-&gt;getBinaryContent()-&gt;getMimeType()); $media-&gt;setSize($media-&gt;getBinaryContent()-&gt;getSize()); } $media-&gt;setProviderStatus(MediaInterface::STATUS_OK); } /** * {@inheritdoc} */ public function updateMetadata(MediaInterface $media, $force = true) { // this is now optimized at all!!! $path = tempnam(sys_get_temp_dir(), 'sonata_update_metadata'); $fileObject = new \SplFileObject($path, 'w'); $fileObject-&gt;fwrite($this-&gt;getReferenceFile($media)-&gt;getContent()); $media-&gt;setSize($fileObject-&gt;getSize()); } /** * {@inheritdoc} */ public function generatePublicUrl(MediaInterface $media, $format) { if ($format == 'reference') { $path = $this-&gt;getReferenceImage($media); } else { // @todo: fix the asset path $path = sprintf('sonatamedia/files/%s/file.png', $format); } return $this-&gt;getCdn()-&gt;getPath($path, $media-&gt;getCdnIsFlushable()); } /** * {@inheritdoc} */ public function getHelperProperties(MediaInterface $media, $format, $options = array()) { return array_merge(array( 'title' =&gt; $media-&gt;getName(), 'thumbnail' =&gt; $this-&gt;getReferenceImage($media), 'file' =&gt; $this-&gt;getReferenceImage($media), ), $options); } /** * {@inheritdoc} */ public function generatePrivateUrl(MediaInterface $media, $format) { if ($format == 'reference') { return $this-&gt;getReferenceImage($media); } return false; } /** * Set the file contents for an image. * * @param \Sonata\MediaBundle\Model\MediaInterface $media * @param string $contents path to contents, defaults to MediaInterface BinaryContent */ protected function setFileContents(MediaInterface $media, $contents = null) { $file = $this-&gt;getFilesystem()-&gt;get(sprintf('%s/%s', $this-&gt;generatePath($media), $media-&gt;getProviderReference()), true); if (!$contents) { $contents = $media-&gt;getBinaryContent()-&gt;getRealPath(); } $metadata = $this-&gt;metadata ? $this-&gt;metadata-&gt;get($media, $file-&gt;getName()) : array(); $file-&gt;setContent(file_get_contents($contents), $metadata); } /** * @param \Sonata\MediaBundle\Model\MediaInterface $media * * @return string */ protected function generateReferenceName(MediaInterface $media) { return sha1($media-&gt;getName().rand(11111, 99999)).'.'.$media-&gt;getBinaryContent()-&gt;guessExtension(); } /** * {@inheritdoc} */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) { // build the default headers $headers = array_merge(array( 'Content-Type' =&gt; $media-&gt;getContentType(), 'Content-Disposition' =&gt; sprintf('attachment; filename="%s"', $media-&gt;getMetadataValue('filename')), ), $headers); if (!in_array($mode, array('http', 'X-Sendfile', 'X-Accel-Redirect'))) { throw new \RuntimeException('Invalid mode provided'); } if ($mode == 'http') { if ($format == 'reference') { $file = $this-&gt;getReferenceFile($media); } else { $file = $this-&gt;getFilesystem()-&gt;get($this-&gt;generatePrivateUrl($media, $format)); } return new StreamedResponse(function () use ($file) { echo $file-&gt;getContent(); }, 200, $headers); } if (!$this-&gt;getFilesystem()-&gt;getAdapter() instanceof \Sonata\MediaBundle\Filesystem\Local) { throw new \RuntimeException('Cannot use X-Sendfile or X-Accel-Redirect with non \Sonata\MediaBundle\Filesystem\Local'); } $filename = sprintf('%s/%s', $this-&gt;getFilesystem()-&gt;getAdapter()-&gt;getDirectory(), $this-&gt;generatePrivateUrl($media, $format) ); return new BinaryFileResponse($filename, 200, $headers); } /** * {@inheritdoc} */ public function validate(ErrorElement $errorElement, MediaInterface $media) { if (!$media-&gt;getBinaryContent() instanceof \SplFileInfo) { return; } if ($media-&gt;getBinaryContent() instanceof UploadedFile) { $fileName = $media-&gt;getBinaryContent()-&gt;getClientOriginalName(); } elseif ($media-&gt;getBinaryContent() instanceof File) { $fileName = $media-&gt;getBinaryContent()-&gt;getFilename(); } else { throw new \RuntimeException(sprintf('Invalid binary content type: %s', get_class($media-&gt;getBinaryContent()))); } if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), $this-&gt;allowedExtensions)) { $errorElement -&gt;with('binaryContent') -&gt;addViolation('Invalid extensions') -&gt;end(); } if (!in_array($media-&gt;getBinaryContent()-&gt;getMimeType(), $this-&gt;allowedMimeTypes)) { $errorElement -&gt;with('binaryContent') -&gt;addViolation('Invalid mime type : '.$media-&gt;getBinaryContent()-&gt;getMimeType()) -&gt;end(); } } } </code></pre> <p>When I push create and edit button, the file pass the validation, save in DDBB and file in server, but in URL <strong>/admin/sonata/media/media/233/edit?provider=sonata.media.provider.zip&amp;context=eag_zip</strong> I get this Error message:</p> <blockquote> <p>Unable to find template "" in SonataMediaBundle:MediaAdmin:edit.html.twig at line 48.</p> </blockquote> <p>Trying to go to <strong>/admin/sonata/media/media/list?provider=sonata.media.provider.zip&amp;context=eag_zip</strong> or <strong>/admin/sonata/media/media/list?context=eag_zip</strong></p> <blockquote> <p>Unable to find template "" in SonataMediaBundle:MediaAdmin:inner_row_media.html.twig at line 19.</p> </blockquote> <p>I don't know to solve it.</p> <p>any help would be welcome</p> <p>thanks a lot</p> </div>

如何使用Cakephp-File-Storage保存图像?

<div class="post-text" itemprop="text"> <p><strong>UPDATE</strong></p> <p>So I added some logs to the action upload in ProductsController and the method upload in MediasTable to find out what is happening. The entity from ProductsController <code>this-&gt;Products-&gt;Medias-&gt;newEntity()</code> was pass to MediasTable but it wasn't save.</p> <p><a href="https://i.stack.imgur.com/bHsRH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bHsRH.png" alt="enter image description here"></a></p> <p>It is necessary to upload the file to save the data in the db? Like if all the data is ok but the file is no present the event will be reject the data and do nothing in the db?</p> <hr> <p>I'm using cakephp 3.1 with the file-storage plugin. I'm following the quickstart guide from the docs: <a href="https://github.com/burzum/cakephp-file-storage/blob/1.0/docs/Tutorials/Quick-Start.md" rel="nofollow noreferrer">Quick-Start</a> but I don't understand some parts and doesn't upload, insert in database neither make thumbnails.</p> <p>This is my database:</p> <pre><code>CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, product_name VARCHAR(255) NOT NULL, quantity INT NOT NULL, sold INT NOT NULL, description VARCHAR(1000), price DECIMAL(7,2) NOT NULL, old_price DECIMAL(7,2) NOT NULL, visited INT NOT NULL, status INT NOT NULL, created DATETIME, modified DATETIME ); CREATE TABLE media_types ( id INT AUTO_INCREMENT PRIMARY KEY, name_media_type VARCHAR(255) NOT NULL, created DATETIME, modified DATETIME ); CREATE TABLE medias ( id INT AUTO_INCREMENT PRIMARY KEY, media_type_id INT NOT NULL, product_id INT NOT NULL, path VARCHAR(255) NOT NULL, created DATETIME, modified DATETIME, FOREIGN KEY media_type_key (media_type_id) REFERENCES media_types(id), FOREIGN KEY product_key (product_id) REFERENCES products(id) ); </code></pre> <p>MediasTable:</p> <pre><code>... use Burzum\FileStorage\Model\Table\ImageStorageTable; class MediasTable extends ImageStorageTable { public function initialize(array $config) { parent::initialize($config); $this-&gt;table('medias'); $this-&gt;displayField('id'); $this-&gt;primaryKey('id'); $this-&gt;addBehavior('Timestamp'); $this-&gt;belongsTo('MediaTypes', [ 'foreignKey' =&gt; 'media_type_id', 'joinType' =&gt; 'INNER' ]); $this-&gt;belongsTo('Products', [ 'foreignKey' =&gt; 'product_id', 'joinType' =&gt; 'INNER' ]); } ... public function upload($productId, $entity) { $media = $this-&gt;patchEntity($entity, [ 'adapter' =&gt; 'Local', 'model' =&gt; 'Media', 'foreign_key' =&gt; $productId ]); Log::write('debug', $media); return $this-&gt;save($media); } } </code></pre> <p>ProductsTable:</p> <pre><code>class ProductsTable extends Table { public function initialize(array $config) { parent::initialize($config); $this-&gt;table('products'); $this-&gt;displayField('id'); $this-&gt;primaryKey('id'); $this-&gt;addBehavior('Timestamp'); $this-&gt;hasMany('Medias', [ 'className' =&gt; 'Medias', 'foreignKey' =&gt; 'foreign_key', 'conditions' =&gt; [ 'Medias.model' =&gt; 'Media' ] ]); } ... } </code></pre> <p>ProductsController:</p> <pre><code>class ProductsController extends AppController { public function upload($productId = null) { $productId = 2; $entity = $this-&gt;Products-&gt;Medias-&gt;newEntity(); if ($this-&gt;request-&gt;is(['post', 'put'])) { $entity = $this-&gt;Products-&gt;Medias-&gt;patchEntity( $entity, $this-&gt;request-&gt;data ); if ($this-&gt;Products-&gt;Medias-&gt;upload($productId, $entity)) { $this-&gt;Flash-&gt;set(__('Upload successful!')); } } $this-&gt;set('productImage', $entity); } ... } </code></pre> <p>In config/local_store.php is the same as the example (I include this file in boostrap.php)</p> <pre><code>... $listener = new LocalFileStorageListener(); EventManager::instance()-&gt;on($listener); $listener = new ImageProcessingListener(); EventManager::instance()-&gt;on($listener); Configure::write('FileStorage', [ 'imageSizes' =&gt; [ 'Medias' =&gt; [ 'large' =&gt; [ ... ]); FileStorageUtils::generateHashes(); StorageManager::config('Local', [ 'adapterClass' =&gt; '\Gaufrette\Adapter\Local', 'adapterOptions' =&gt; [TMP, true], 'class' =&gt; '\Gaufrette\Filesystem' ]); </code></pre> <p>upload.ctp</p> <pre><code>echo $this-&gt;Form-&gt;create($productImage, array('type' =&gt; 'file')); echo $this-&gt;Form-&gt;file('file'); echo $this-&gt;Form-&gt;error('file'); echo $this-&gt;Form-&gt;submit(__('Upload')); echo $this-&gt;Form-&gt;end(); </code></pre> <p>In the quick start there is two upload methods: uploadImage and uploadDocument but in the controller they use "upload".</p> <p>There is another association in Products in the example, I need this?:</p> <pre><code> $this-&gt;hasMany('Documents', [ 'className' =&gt; 'FileStorage.FileStorage', 'foreignKey' =&gt; 'foreign_key', 'conditions' =&gt; [ 'Documents.model' =&gt; 'ProductDocument' ] ]); </code></pre> <p>I found this question (from there is the db I'm using) <a href="https://stackoverflow.com/questions/32031237/getting-started-with-cakephp-file-storage-quickstart-guide">Getting Started with cakephp-file-storage quickstart guide</a> and upload and insert but doesn't make the thumbnails and if I change the table to ImageStoreTable shows an error "Class not found"</p> <p>So if anybody can help me I will be very grateful!</p> </div>

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

Python可以这样学(第一季:Python内功修炼)

Python可以这样学(第一季:Python内功修炼)

C++语言基础视频教程

C++语言基础视频教程

Python可以这样学(第四季:数据分析与科学计算可视化)

Python可以这样学(第四季:数据分析与科学计算可视化)

网络工程师小白入门--【思科CCNA、华为HCNA等网络工程师认证】

网络工程师小白入门--【思科CCNA、华为HCNA等网络工程师认证】

Python数据分析与挖掘

Python数据分析与挖掘

微信小程序开发实战之番茄时钟开发

微信小程序开发实战之番茄时钟开发

软件测试2小时入门

软件测试2小时入门

相关热词 c#跨线程停止timer c#批量写入sql数据库 c# 自动安装浏览器 c#语言基础考试题 c# 偏移量打印是什么 c# 绘制曲线图 c#框体中的退出函数 c# 按钮透明背景 c# idl 混编出错 c#在位置0处没有任何行
立即提问