在我们使用ZendFramework 1的项目中,我们需要为某些文件操作添加S3支持。逻辑上考虑的是Zend_Cloud_StorageService,因此我们只需更改适配器即可轻松切换到不同类型的存储。但AWS最新区域仅支持V4身份验证,因此zend附带的默认S3适配器不兼容。
$storage = Zend_Cloud_StorageService_Factory::getAdapter([
Zend_Cloud_StorageService_Factory::STORAGE_ADAPTER_KEY => 'Zend_Cloud_StorageService_Adapter_S3',
Zend_Cloud_StorageService_Adapter_S3::AWS_ACCESS_KEY => '....key....',
Zend_Cloud_StorageService_Adapter_S3::AWS_SECRET_KEY => '...secret...',
Zend_Cloud_StorageService_Adapter_S3::BUCKET_NAME => '..bucket-name..'
]);
$storage->listItems('/');
AWS响应
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>InvalidRequest</Code><Message>The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.</Message>
<RequestId>...5F343398....</RequestId>
<HostId>.....bliEk9xnCWr....</HostId>
</Error>
是否有一些更新的S3适配器可用于Zend Framework 1
的Zend云存储服务