gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:47:31 28 4
gpt4 key购买 nike

谁能帮我弄清楚如何让 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com