2

尝试在 Symfony2 Web 应用程序上使用 VichUploader、Gaufrette 和 AWS SDK v2 将文件上传到我的存储桶时出现此错误。听起来像是 API 调用的问题。它给了我一个拒绝访问(错误 500 内部服务器错误)有人可以在这里帮助我吗?

配置:

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:
    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

堆栈跟踪:

[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
4

1 回答 1

0

原来我的桶区域是错误的。我以为我在 us-west-2 中创建了它,但显然它没有设置区域。

改变:

region: us-west-2

region: ~

于 2015-04-21T15:54:43.593 回答