尝试在 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: AwsS3S3Client #GaufretteAdapterAwsS3
factory_class: AwsS3S3Client
factory_method: factory
arguments:
-
key: key
secret: key
region: us-west-2
堆栈跟踪:
[1] AwsS3ExceptionAccessDeniedException: Access Denied
at n/a
in C:xampp2htdocsWebProjectvendorawsaws-sdk-phpsrcAwsCommonExceptionNamespaceExceptionFactory.php line 91
at AwsCommonExceptionNamespaceExceptionFactory->createException('AwsS3ExceptionAccessDeniedException', object(EntityEnclosingRequest), object(Response), array('code' => 'AccessDenied', 'message' => 'Access Denied', 'type' => 'client', 'request_id' => 'B4966F7BBECF30F3', 'parsed' => object(SimpleXMLElement)))
in C:xampp2htdocsWebProjectvendorawsaws-sdk-phpsrcAwsCommonExceptionNamespaceExceptionFactory.php line 76
at AwsCommonExceptionNamespaceExceptionFactory->fromResponse(object(EntityEnclosingRequest), object(Response))
in C:xampp2htdocsWebProjectvendorawsaws-sdk-phpsrcAwsCommonExceptionExceptionListener.php line 55
at AwsCommonExceptionExceptionListener->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:xampp2htdocsWebProjectappcachedevclasses.php line 1790
at SymfonyComponentEventDispatcherEventDispatcher->doDispatch(array(array(object(ExceptionListener), 'onRequestError'), array('GuzzleHttpMessageRequest', 'onRequestError')), 'request.error', object(Event))
in C:xampp2htdocsWebProjectappcachedevclasses.php line 1723
at SymfonyComponentEventDispatcherEventDispatcher->dispatch('request.error', object(Event))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpMessageRequest.php line 589
at GuzzleHttpMessageRequest->processResponse(array('handle' => object(CurlHandle)))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpMessageRequest.php line 378
at GuzzleHttpMessageRequest->setState('complete', array('handle' => object(CurlHandle)))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpMessageEntityEnclosingRequest.php line 49
at GuzzleHttpMessageEntityEnclosingRequest->setState('complete', array('handle' => object(CurlHandle)))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMulti.php line 303
at GuzzleHttpCurlCurlMulti->processResponse(object(EntityEnclosingRequest), object(CurlHandle), array('msg' => '1', 'result' => '0', 'handle' => 'Resource id #2420'))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMulti.php line 257
at GuzzleHttpCurlCurlMulti->processMessages()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMulti.php line 240
at GuzzleHttpCurlCurlMulti->executeHandles()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMulti.php line 224
at GuzzleHttpCurlCurlMulti->perform()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMulti.php line 111
at GuzzleHttpCurlCurlMulti->send()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpCurlCurlMultiProxy.php line 94
at GuzzleHttpCurlCurlMultiProxy->send()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleHttpClient.php line 284
at GuzzleHttpClient->send(object(EntityEnclosingRequest))
in C:xampp2htdocsWebProjectvendorawsaws-sdk-phpsrcAwsCommonClientAbstractClient.php line 256
at AwsCommonClientAbstractClient->send(object(EntityEnclosingRequest))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleServiceClient.php line 136
at GuzzleServiceClient->execute(object(S3Command))
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleServiceCommandAbstractCommand.php line 153
at GuzzleServiceCommandAbstractCommand->execute()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleServiceCommandAbstractCommand.php line 189
at GuzzleServiceCommandAbstractCommand->getResult()
in C:xampp2htdocsWebProjectvendorguzzleguzzlesrcGuzzleServiceClient.php line 76
at GuzzleServiceClient->__call('CreateBucket', array(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2')))
in C:xampp2htdocsWebProjectvendorawsaws-sdk-phpsrcAwsCommonClientAbstractClient.php line 104
at AwsCommonClientAbstractClient->__call('createBucket', array(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2')))
in C:xampp2htdocsWebProjectvendorknplabsgaufrettesrcGaufretteAdapterAwsS3.php line 254
at AwsS3S3Client->createBucket(array('Bucket' => 'eventori', 'LocationConstraint' => 'us-west-2'))
in C:xampp2htdocsWebProjectvendorknplabsgaufrettesrcGaufretteAdapterAwsS3.php line 254
at GaufretteAdapterAwsS3->ensureBucketExists()
in C:xampp2htdocsWebProjectvendorknplabsgaufrettesrcGaufretteAdapterAwsS3.php line 125
at GaufretteAdapterAwsS3->write('5535ad181397d.png', '')
in C:xampp2htdocsWebProjectvendorknplabsgaufrettesrcGaufretteFilesystem.php line 122
at GaufretteFilesystem->write('5535ad181397d.png', '', true)
in C:xampp2htdocsWebProjectvendorvichuploader-bundleStorageGaufretteStorage.php line 56
at VichUploaderBundleStorageGaufretteStorage->doUpload(object(PropertyMapping), object(UploadedFile), '', '5535ad181397d.png')
in C:xampp2htdocsWebProjectvendorvichuploader-bundleStorageAbstractStorage.php line 67
at VichUploaderBundleStorageAbstractStorage->upload(object(Image), object(PropertyMapping))
in C:xampp2htdocsWebProjectvendorvichuploader-bundleHandlerUploadHandler.php line 64
at VichUploaderBundleHandlerUploadHandler->upload(object(Image), 'imageFile')
in C:xampp2htdocsWebProjectappcachedevappDevDebugProjectContainer.php line 9126
at VichUploaderBundleHandlerUploadHandler_00000000534e394600000000143551d5->upload(object(Image), 'imageFile')
in C:xampp2htdocsWebProjectvendorvichuploader-bundleEventListenerDoctrineUploadListener.php line 41
at VichUploaderBundleEventListenerDoctrineUploadListener->prePersist(object(LifecycleEventArgs))
in C:xampp2htdocsWebProjectvendorsymfonysymfonysrcSymfonyBridgeDoctrineContainerAwareEventManager.php line 63
at SymfonyBridgeDoctrineContainerAwareEventManager->dispatchEvent('prePersist', object(LifecycleEventArgs))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMEventListenersInvoker.php line 117
at DoctrineORMEventListenersInvoker->invoke(object(ClassMetadata), 'prePersist', object(Image), object(LifecycleEventArgs), '4')
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMUnitOfWork.php line 896
at DoctrineORMUnitOfWork->persistNew(object(ClassMetadata), object(Image))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMUnitOfWork.php line 1683
at DoctrineORMUnitOfWork->doPersist(object(Image), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMUnitOfWork.php line 2229
at DoctrineORMUnitOfWork->cascadePersist(object(Event), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMUnitOfWork.php line 1702
at DoctrineORMUnitOfWork->doPersist(object(Event), array('00000000534e3b0d00000000143551d5' => object(Event), '00000000534e272c00000000143551d5' => object(User), '00000000534e3df700000000143551d5' => object(Image)))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMUnitOfWork.php line 1639
at DoctrineORMUnitOfWork->persist(object(Event))
in C:xampp2htdocsWebProjectvendordoctrineormlibDoctrineORMEntityManager.php line 579
at DoctrineORMEntityManager->persist(object(Event))
in C:xampp2htdocsWebProjectsrcETCoreBundleControllerEventController.php line 63
at ETCoreBundleControllerEventController->createAction(object(Request))
in line
at call_user_func_array(array(object(EventController), 'createAction'), array(object(Request)))
in C:xampp2htdocsWebProjectappbootstrap.php.cache line 3029
at SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), '1')
in C:xampp2htdocsWebProjectappbootstrap.php.cache line 2991
at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), '1', true)
in C:xampp2htdocsWebProjectappbootstrap.php.cache line 3140
at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
in C:xampp2htdocsWebProjectappbootstrap.php.cache line 2384
at SymfonyComponentHttpKernelKernel->handle(object(Request))
in C:xampp2htdocsWebProjectwebapp_dev.php line 28
事实证明我的存储桶区域是错误的。我以为我已经在 us-west-2 中创建了它,但显然它没有设置区域。
改变:
region: us-west-2
自
region: ~