在Amazon S3中上传图像

时间:2017-01-18 08:10:17

标签: php symfony

我尝试使用本教程https://florian.ec/articles/upload-files-to-amazon-s3-with-symfony2-and-gaufrette/在s3中上传图片,但是当我访问此函数时,我收到错误:“localhost页面无效”:$ uploader = $ this-> get( 'kdm_storage.photo_uploader');

      $uploader = $this->get('kdm_storage.photo_uploader');
    $uploadedUrl = $uploader->upload($logo);
    $t = $this->container->getParameter('amazon_s3_base_url') . $uploadedUrl;

的services.xml

 <parameters>
    <parameter key="kdm_storage.photo_uploader.class">KDK\Controller\PhotoUploader</parameter>
</parameters>

<services>
    <service id="kdm_storage.photo_uploader" class="%kdm_storage.photo_uploader.class%">
        <argument type="service" id="photo_storage_filesystem" />
    </service>
</services>

config.yml

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

0 个答案:

没有答案