将aws / aws-sdk-php与Google云端存储配合使用
Google云端存储(与Google云端硬盘不同)似乎与S3 API兼容:
https://developers.google.com/storage/docs/migrating#migration-simple 有谁知道我是否可以使用aws / aws-sdk-php(https://packagist.org/packages/aws/aws-sdk-php)软件包并将其配置为连接到我的Google云端存储而不是AWS S3? 我试过以下代码: <?php use AwsS3S3Client; use LeagueFlysystemFilesystem; use LeagueFlysystemAdapterAwsS3 as Adapter; require_once 'vendor/autoload.php'; error_reporting(E_ALL & ~E_NOTICE); ini_set('display_errors',1); $client = S3Client::factory(array( 'key' => 'MY_GCS_KEY','secret' => 'MY_GCS_SECRET','endpoint' => 'storage.googleapis.com' )); $filesystem = new Filesystem(new Adapter($client,'MY_GCS_BUCKET')); $filesystem->write('filename.txt','contents'); 但这给了我一个错误:
任何人都知道如何或者我是否可以正确设置aws / aws-sdk-php包以连接到Google云端存储? 编辑 以下是使其工作的代码: <?php use AwsS3S3Client; use LeagueFlysystemFilesystem; use LeagueFlysystemAdapterAwsS3 as Adapter; require_once 'vendor/autoload.php'; $client = S3Client::factory(array( 'key' => 'MY_GCS_KEY','base_url' => 'https://storage.googleapis.com' )); $filesystem = new Filesystem(new Adapter($client,'contents'); 解决方法
端点是错误的密钥.它应该是base_url.
http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#setting-a-custom-endpoint (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |