php - PHP GAE 上的 Amazon S3 无法使用 curl 扩展

标签 php google-app-engine amazon-s3

谁能帮我弄清楚如何让 S3 在我的 php 应用程序引擎(运行时: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.ini 中使用 extension = "curl.so" 时出错

15:09:52.614 A problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. (Error code 204)

编辑:

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

最佳答案

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

关于php - PHP GAE 上的 Amazon S3 无法使用 curl 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28992685/

相关文章:

java - Java 中的 JSON 解码

java - Google Cloud Storage API 和可恢复上传返回 null Location header

python - GAE/Python - 从主类而不是从被调用的方法重定向工作

amazon-web-services - 在CloudFormation中创建 "Mappings"的目的是什么?

amazon-web-services - 定义为 null 的 bean 'AmazonEc2InstanceDataPropertySourcePostProcessor' 无法注册

php - 使用 php 从 shell 启动 sudo

php - 如何对两个不同的数组值执行真假比较

javascript - 使用提交按钮而不是 anchor 标记打开新链接

java - 查询 Google App Engine 数据存储区时出现并发问题

file - 在同一区域将大文件从 S3 下载到 EC2 的最快方法是什么?