Laravel Amazon S3软件包突然停止工作

时间:2018-12-28 01:33:01

标签: laravel amazon-web-services laravel-5 amazon-s3 aws-sdk

我一直在使用此代码:

  private function pushToS3($photo)
  {
    return $this->s3->putObject([
      'Bucket'        => $this->bucket,
      'Key'           => $photo->path,
      'ContentType'   => $this->fileInfo['mimetype'],
      'ContentLength' => filesize($this->tempFileName),
      'SourceFile'    => $this->tempFileName
    ]);
  }

突然之间,我的队列中出现了很多有关文件不匹配的错误,我也不知道如何解决。这是堆栈跟踪。其他人是否突然遇到“?”的问题?如果是,您是怎么解决的?

错误是:提供的'x-amz-content-sha256'标头与计算出的标头不匹配。

exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "PutObject" on "https://real-estate-listings.s3.amazonaws.com/naples/prestwick-place-at-lely-resort/217006408/0.jpg"; AWS HTTP error: Client error: `PUT https://real-estate-listings.s3.amazonaws.com/naples/prestwick-place-at-lely-resort/217006408/0.jpg` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>XAmzContentSHA256Mismatch</Code><Message>The provided 'x-amz-content (truncated...)
 XAmzContentSHA256Mismatch (client): The provided 'x-amz-content-sha256' header does not match what was computed. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>XAmzContentSHA256Mismatch</Code><Message>The provided 'x-amz-content-sha256' header does not match what was computed.</Message><ClientComputedContentSHA256>b14142ad250f999738ffb58372fc2022ded3faca2a4fd12ad2110df6889affce</ClientComputedContentSHA256><S3ComputedContentSHA256>fd657de6b5f5e3137de3a44e41358eb53f28878d1026e26a506386364d4144e1</S3ComputedContentSHA256><RequestId>CC785BA3A416CE14</RequestId><HostId>k3lstjw0kT3mTcfHgeYmuZsvtYGwAfaBmyrDnai1KrWuePeZPnDN8iyFbdINr4sVbD8xtxP0+Gk=</HostId></Error>'

GuzzleHttp\Exception\ClientException: Client error: `PUT https://real-estate-listings.s3.amazonaws.com/naples/prestwick-place-at-lely-resort/217006408/0.jpg` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>XAmzContentSHA256Mismatch</Code><Message>The provided 'x-amz-content (truncated...)
 in /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(98): GuzzleHttp\Promise\TaskQueue->run()
#5 /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(125): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#12 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#13 /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#14 /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(77): Aws\AwsClient->execute(Object(Aws\Command))
#15 /srv/www/listingnaples.com/app/Models/PhotoProcessor.php(172): Aws\AwsClient->__call('putObject', Array)
#16 /srv/www/listingnaples.com/app/Models/PhotoProcessor.php(67): App\Models\PhotoProcessor->pushToS3(Object(App\Models\RetsPhoto))
#17 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(86): App\Models\PhotoProcessor->process()
#18 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(32): App\Models\ListingMigrator->processPhotos()
#19 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(22): App\Models\ListingMigrator->migrate()
#20 /srv/www/listingnaples.com/app/Jobs/ProcessListing.php(44): App\Models\ListingMigrator::migrateListing(Object(App\Models\TempListingNaples), Object(App\Models\RetsFeed))
#21 [internal function]: App\Jobs\ProcessListing->handle()
#22 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#23 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#24 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#25 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#26 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#27 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\ProcessListing))
#28 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\ProcessListing))
#29 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#30 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\ProcessListing), false)
#31 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\SqsJob), Array)
#32 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(327): Illuminate\Queue\Jobs\Job->fire()
#33 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(277): Illuminate\Queue\Worker->process('sqs', Object(Illuminate\Queue\Jobs\SqsJob), Object(Illuminate\Queue\WorkerOptions))
#34 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\SqsJob), 'sqs', Object(Illuminate\Queue\WorkerOptions))
#35 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('sqs', 'ImportQueue', Object(Illuminate\Queue\WorkerOptions))
#36 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('sqs', 'ImportQueue')
#37 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#38 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#39 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#40 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#41 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#42 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#43 /srv/www/listingnaples.com/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#44 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#45 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(901): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#46 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#47 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#48 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#49 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#50 /srv/www/listingnaples.com/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#51 {main}

Next Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://real-estate-listings.s3.amazonaws.com/naples/prestwick-place-at-lely-resort/217006408/0.jpg"; AWS HTTP error: Client error: `PUT https://real-estate-listings.s3.amazonaws.com/naples/prestwick-place-at-lely-resort/217006408/0.jpg` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>XAmzContentSHA256Mismatch</Code><Message>The provided 'x-amz-content (truncated...)
 XAmzContentSHA256Mismatch (client): The provided 'x-amz-content-sha256' header does not match what was computed. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>XAmzContentSHA256Mismatch</Code><Message>The provided 'x-amz-content-sha256' header does not match what was computed.</Message><ClientComputedContentSHA256>b14142ad250f999738ffb58372fc2022ded3faca2a4fd12ad2110df6889affce</ClientComputedContentSHA256><S3ComputedContentSHA256>fd657de6b5f5e3137de3a44e41358eb53f28878d1026e26a506386364d4144e1</S3ComputedContentSHA256><RequestId>CC785BA3A416CE14</RequestId><HostId>k3lstjw0kT3mTcfHgeYmuZsvtYGwAfaBmyrDnai1KrWuePeZPnDN8iyFbdINr4sVbD8xtxP0+Gk=</HostId></Error> in /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:191
Stack trace:
#0 /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(100): Aws\WrappedHttpHandler->parseError(Array, Object(GuzzleHttp\Psr7\Request), Object(Aws\Command), Array)
#1 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(203): Aws\WrappedHttpHandler->Aws\{closure}(Array)
#2 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(174): GuzzleHttp\Promise\Promise::callHandler(2, Array, Array)
#3 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/RejectedPromise.php(40): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}(Array)
#4 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}()
#5 /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(98): GuzzleHttp\Promise\TaskQueue->run()
#6 /srv/www/listingnaples.com/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(125): GuzzleHttp\Handler\CurlMultiHandler->tick()
#7 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#8 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#9 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#10 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#11 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#12 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#13 /srv/www/listingnaples.com/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#14 /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#15 /srv/www/listingnaples.com/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(77): Aws\AwsClient->execute(Object(Aws\Command))
#16 /srv/www/listingnaples.com/app/Models/PhotoProcessor.php(172): Aws\AwsClient->__call('putObject', Array)
#17 /srv/www/listingnaples.com/app/Models/PhotoProcessor.php(67): App\Models\PhotoProcessor->pushToS3(Object(App\Models\RetsPhoto))
#18 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(86): App\Models\PhotoProcessor->process()
#19 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(32): App\Models\ListingMigrator->processPhotos()
#20 /srv/www/listingnaples.com/app/Models/ListingMigrator.php(22): App\Models\ListingMigrator->migrate()
#21 /srv/www/listingnaples.com/app/Jobs/ProcessListing.php(44): App\Models\ListingMigrator::migrateListing(Object(App\Models\TempListingNaples), Object(App\Models\RetsFeed))
#22 [internal function]: App\Jobs\ProcessListing->handle()
#23 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#24 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#25 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#26 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#27 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#28 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(App\Jobs\ProcessListing))
#29 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(App\Jobs\ProcessListing))
#30 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#31 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\ProcessListing), false)
#32 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\SqsJob), Array)
#33 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(327): Illuminate\Queue\Jobs\Job->fire()
#34 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(277): Illuminate\Queue\Worker->process('sqs', Object(Illuminate\Queue\Jobs\SqsJob), Object(Illuminate\Queue\WorkerOptions))
#35 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\SqsJob), 'sqs', Object(Illuminate\Queue\WorkerOptions))
#36 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('sqs', 'ImportQueue', Object(Illuminate\Queue\WorkerOptions))
#37 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('sqs', 'ImportQueue')
#38 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#39 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#40 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#41 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#42 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#43 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#44 /srv/www/listingnaples.com/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#45 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#46 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(901): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#47 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#48 /srv/www/listingnaples.com/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#49 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#50 /srv/www/listingnaples.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#51 /srv/www/listingnaples.com/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#52 {main}

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,我们遇到了一个问题,即大于5MB的任何内容都会产生此错误。

我们试图接受该请求并将其直接上传到S3,但这将花费很长时间,导致S3无法接受已签名的数据。

相反,我添加了一个中间步骤,将文件本地存储在服务器上,然后将该文件上传到S3,然后删除临时本地文件。

try {
    $local = Storage::disk('local');
    $s3 = Storage::disk('s3');

    // Save file locally on server
    $local->put('/path/to/local/file', file_get_contents($request->file('file')));

    // Transfer file to remote storage
    $s3->put('/path/to/remote/file', $local->get('/path/to/local/file'));

    // Remove locally save file
    $local->delete('/path/to/local/file');

} catch (\Exception $e) {
    return response()->json(['error' => $e->getMessage()], 400);
}