Amazon S3 on PHP GAE 不适用于 curl extension


Amazon S3 on PHP GAE not working with curl extension

谁能帮我弄清楚如何让 S3 在我的 php 应用程序引擎上工作(runtime: php55)?

我在某处看到您可以在没有 CURL 的情况下使用它,并找到了 StreamWrapper,但不断出现错误。

Use of undefined constant CURLE_COULDNT_RESOLVE_HOST
Use of undefined constant CURLE_COULDNT_CONNECT
Use of undefined constant CURLE_PARTIAL_FILE
etc..

这是我的代码:

use Aws'S3'S3Client;
use Aws'S3'Exception'S3Exception;
// Instantiate an S3 client
$s3 = S3Client::factory(array('key' => 'KEY','secret' => 'SECRET'));
$s3->registerStreamWrapper(); // don't use curl
//AMAZON S3 BACKUP//
$document_data = "123456";
$s3_object_url = "s3://bucket/folder/file.txt";
$s3_options = stream_context_create(['s3'=>['ACL'=>'bucket-owner-full-control', 'ServerSideEncryption' => 'AES256']]);
$s3_file = fopen($s3_object_url, 'w', false, $s3_options);
fwrite($s3_file, $document_data);
fclose($s3_file);

使用 curl lite 时出错:

PHP Fatal error:  Uncaught exception 'google'appengine'runtime'CurlLiteMethodNotSupportedException' with message 'curl_multi_init' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/CurlLiteStub.php:1391
Stack trace:
#0 /base/data/home/apps/.../vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(50): curl_multi_init()
#1 /base/data/home/apps/.../vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMultiProxy.php(128): Guzzle'Http'Curl'CurlMulti->__construct(1)
#2 /base/data/home/apps/.../vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMultiProxy.php(87): Guzzle'Http'Curl'CurlMultiProxy->getAvailableHandle()
#3 /base/data/home/apps/.../vendor/guzzle/guzzle/src/Guzzle/Http/Client.php(284): Guzzle'Http'Curl'CurlMultiProxy->send()
#4 /base/data/home/apps/.../vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php(256): Guzzle'Http'Client->send(Ob in /base/data/home/runtimes/php/sdk/google/appengine/runtime/CurlLiteStub.php on line 1391

在 php 中使用 extension = "curl.so" 时出错.ini

15:09:52.614 处理此请求的进程遇到问题,导致其退出。这可能会导致新进程用于对应用程序的下一个请求。(错误代码 204)

编辑:

看起来"guzzle"需要启用 curl,所以我在我的 php 中启用了extension = "curl.so".ini它在我的本地主机开发人员中运行良好,没有错误。但当我将其上传到应用程序引擎时不会。

curl 需要的套接字,这些套接字仅适用于启用计费的应用程序 (https://cloud.google.com/appengine/docs/php/sockets/)。您可能还希望考虑"curl lite":https://cloud.google.com/appengine/docs/php/config/php_ini#GAE_directives

尽管 GAE 支持"cURL"——它只是一个包装器,所以一些功能还没有实现——尤其是整个multi_curl_*的事情。

还没有找到停用它的方法 - 但从 SDK v3 不再需要 cURL - 所以你可以尝试一下。