UniSharp / laravel-filemanager

Media gallery with CKEditor, TinyMCE and Summernote support. Built on Laravel file system.
https://unisharp.github.io/laravel-filemanager/
MIT License
2.09k stars 720 forks source link

Upload to aws S3 403 Forbidden but can create folder #896

Open chrizz1001 opened 4 years ago

chrizz1001 commented 4 years ago

Hi, I run the lates version and use tinyMCE 5.2. When I try to upload to s3 bucket I can create folders but I cannot upload files. When I try manually Laravel upload to s3 it is working.

I can browse the s3 bucket with the filemanager and create folders. no problem. But I am not able to upload a file.

The ajax request returns ["Invalid upload request"]' the laravel log tells me this:

[2020-03-11 21:13:24] production.INFO: exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "PutObject" on "https://xxxxxxx.eu-central-1.amazonaws.com/photos/52/foto_all_for_one.jpg"; AWS HTTP error: Client error: `PUT https://xxxxxxx.s3.eu-central-1.amazonaws.com/photos/52/foto_all_for_one.jpg` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>8D641D (truncated...)
 AccessDenied (client): Access Denied - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>8D641D3A53DCBD5D</RequestId><HostId>M5WUV7NTiHnwLQvKdhEYVX18mh4VECCvkEE+I3439YsWfcPEZ9z1Tx0EsY3DDRQd/fWn0D7VMGA=</HostId></Error>'

GuzzleHttp\Exception\ClientException: Client error: `PUT https://xxxxxxx.s3.eu-central-1.amazonaws.com/photos/52/foto_all_for_one.jpg` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>8D641D (truncated...)
 in /var/app/current/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /var/app/current/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /var/app/current/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /var/app/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(118): GuzzleHttp\Promise\TaskQueue->run()
#5 /var/app/current/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(145): GuzzleHttp\Handler\CurlMultiHandler->tick()
#6 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#7 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#12 /var/app/current/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#13 /var/app/current/vendor/aws/aws-sdk-php/src/S3/S3ClientTrait.php(34): GuzzleHttp\Promise\Promise->wait()
#14 /var/app/current/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(610): Aws\S3\S3Client->upload('xxxxxxx', 'photos/52/foto_...', Resource id #43, 'public-read', Array)
#15 /var/app/current/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php(392): League\Flysystem\AwsS3v3\AwsS3Adapter->upload('photos/52/foto_...', Resource id #43, Object(League\Flysystem\Config))
#16 /var/app/current/vendor/league/flysystem/src/Filesystem.php(122): League\Flysystem\AwsS3v3\AwsS3Adapter->writeStream('photos/52/foto_...', Resource id #43, Object(League\Flysystem\Config))
#17 /var/app/current/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(194): League\Flysystem\Filesystem->putStream('photos/52/foto_...', Resource id #43, Object(League\Flysystem\Config))
#18 /var/app/current/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(228): Illuminate\Filesystem\FilesystemAdapter->put('photos/52/foto_...', Resource id #43, Array)
#19 /var/app/current/vendor/unisharp/laravel-filemanager/src/LfmStorageRepository.php(48): Illuminate\Filesystem\FilesystemAdapter->putFileAs('photos/52/foto_...', Object(Illuminate\Http\UploadedFile), 'foto_all_for_on...', 'public')
#20 /var/app/current/vendor/unisharp/laravel-filemanager/src/LfmPath.php(297): UniSharp\LaravelFilemanager\LfmStorageRepository->save(Object(Illuminate\Http\UploadedFile))
#21 /var/app/current/vendor/unisharp/laravel-filemanager/src/LfmPath.php(228): UniSharp\LaravelFilemanager\LfmPath->saveFile(Object(Illuminate\Http\UploadedFile), 'foto_all_for_on...')
#22 /var/app/current/vendor/unisharp/laravel-filemanager/src/Controllers/UploadController.php(34): UniSharp\LaravelFilemanager\LfmPath->upload(Object(Illuminate\Http\UploadedFile))
#23 [internal function]: UniSharp\LaravelFilemanager\Controllers\UploadController->upload()
#24 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#25 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('upload', Array)
#26 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(UniSharp\LaravelFilemanager\Controllers\UploadController), 'upload')
#27 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#28 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Routing\Route->run()
#29 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /var/app/current/vendor/unisharp/laravel-filemanager/src/Middlewares/MultiUser.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): UniSharp\LaravelFilemanager\Middlewares\MultiUser->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /var/app/current/vendor/unisharp/laravel-filemanager/src/Middlewares/CreateDefaultFolder.php(25): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): UniSharp\LaravelFilemanager\Middlewares\CreateDefaultFolder->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /var/app/current/app/Http/Middleware/LocaleMiddleware.php(60): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): App\Http\Middleware\LocaleMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/app/current/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /var/app/current/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /var/app/current/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#52 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /var/app/current/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#56 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#57 /var/app/current/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#60 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#61 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php(684): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#62 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php(659): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#63 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#64 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php(614): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#65 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#66 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#67 /var/app/current/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#68 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#69 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#70 /var/app/current/vendor/spatie/laravel-cors/src/Cors.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#71 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Spatie\Cors\Cors->handle(Object(Illuminate\Http\Request), Object(Closure))
#72 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#73 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#74 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#75 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#76 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#77 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#78 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#79 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#80 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#81 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#82 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#83 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#84 /var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#85 /var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#86 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#87 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#88 /var/app/current/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#89 {main}
flaviopc commented 4 years ago

Same problem

abishekrsrikaanth commented 4 years ago

This should fix it. PR https://github.com/UniSharp/laravel-filemanager/pull/982