我正在尝试使用aws php sdk将14MB目录上传到s3。这些是以下场景及其结果
我使用的以下代码
require('application/classes/vendor/autoload.php');
use Aws\S3\S3Client;
use Aws\Common\Credentials\Credentials;
use Aws\S3\Sync\UploadSyncBuilder;
use Guzzle\Log\ClosureLogAdapter;
use Guzzle\Plugin\Log\LogPlugin;
$newCredentials = new Credentials("API_KEY", "SECRET_KEY");
$s3 = S3Client::factory();
//$logPlugin = Guzzle\Plugin\Log\LogPlugin::getDebugPlugin();
$stream = fopen('out.log', 'w');
$logPlugin = new LogPlugin(new ClosureLogAdapter(function ($m) use ($stream) {
fwrite($stream, $m . PHP_EOL);
}), "# Request:\n{request}\n\n# Response:\n{response}\n\n# Errors: {curl_code} {curl_error}", true);
$s3->addSubscriber($logPlugin);
$s3->setCredentials($newCredentials);
$s3->setRegion("us-east-1");
UploadSyncBuilder::getInstance()
->setClient($s3)
->setBucket("BUCKET")
->setAcl("public-read")
->uploadFromDirectory("/mnt/1410503562Welcome to Leap!.zip_ext")
->setKeyPrefix("customs3/game10906/1410501964WelcometoLeap.zip_ext")
->setConcurrency(5)
->build()
->transfer();
例外
PHP Fatal error: Uncaught exception 'Guzzle\Service\Exception\CommandTransferException' with message 'Errors during multi transfer (Guzzle\Http\Exception\RequestException) ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php line 569
Error completing request
#0 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(378): Guzzle\Http\Message\Request->processResponse(Array)
#1 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php(49): Guzzle\Http\Message\Request->setState('complete', Array)
#2 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(286): Guzzle\Http\Message\EntityEnclosingRequest->setState('complete', Array)
#3 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(244): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#4 ./application/classes/vendor/guzzle/guzzle in /vol/selfserve/application/classes/vendor/guzzle/guzzle/src/Guzzle/Service/Exception/CommandTransferException.php on line 25
我有设置日志来调试和挖掘Guzzle库。我发现当它失败时,对于请求没有响应。当我将并发设置为1时,它会成功,但需要很长时间。它甚至在2的并发性时都失败了。
如果任何文件失败,整个上传将失败,使其处于部分上传状态。如果出现问题,我找不到任何方法来设置重试的选项。
感谢您的帮助!
答案 0 :(得分:0)
在与AWS支持人员联系后,我能够在他们的帮助下解决这个问题。问题出在guzzle库中。以下是AWS支持的回复
当cURL无法回放流时发生此错误,而不是 将错误与curl句柄相关联。我们已将支票添加到帐户中 对于这种情况并自动重试。请确保他们 正在使用最新版本的SDK和Guzzle版本3.9.2+。