From 7262f6a55038eca08e66eed44b80625c064be2f3 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 27 Jan 2018 21:52:24 +0000 Subject: [PATCH] Fix uploading files to S3 --- app/Http/Controllers/MicropubController.php | 6 +++--- app/Jobs/ProcessMedia.php | 8 +++++--- changelog.md | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/MicropubController.php b/app/Http/Controllers/MicropubController.php index 149f8acc..7c26a615 100644 --- a/app/Http/Controllers/MicropubController.php +++ b/app/Http/Controllers/MicropubController.php @@ -110,7 +110,7 @@ class MicropubController extends Controller public function get(): JsonResponse { try { - $tokenData = $this->tokenService->validateToken(request()->bearerToken()); + $tokenData = $this->tokenService->validateToken(request()->input('access_token')); } catch (InvalidTokenException $e) { return $this->invalidTokenResponse(); } @@ -162,7 +162,7 @@ class MicropubController extends Controller public function media(): JsonResponse { try { - $tokenData = $this->tokenService->validateToken(request()->bearerToken()); + $tokenData = $this->tokenService->validateToken(request()->input('access_token')); } catch (InvalidTokenException $e) { return $this->invalidTokenResponse(); } @@ -289,7 +289,7 @@ class MicropubController extends Controller private function saveFile(UploadedFile $file): string { $filename = Uuid::uuid4() . '.' . $file->extension(); - Storage::disk('local')->put($filename, $file); + Storage::disk('local')->putFileAs('', $file, $filename); return $filename; } diff --git a/app/Jobs/ProcessMedia.php b/app/Jobs/ProcessMedia.php index dcac4a82..9efbe37a 100644 --- a/app/Jobs/ProcessMedia.php +++ b/app/Jobs/ProcessMedia.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Jobs; +use Illuminate\Http\File; use Illuminate\Bus\Queueable; use Intervention\Image\ImageManager; use Illuminate\Queue\SerializesModels; @@ -36,9 +37,10 @@ class ProcessMedia implements ShouldQueue */ public function handle(ImageManager $manager) { - Storage::disk('s3')->put( - 'media/' . $this->filename, - storage_path('app') . '/' . $this->filename + Storage::disk('s3')->putFileAs( + 'media', + new File(storage_path('app') . '/' . $this->filename), + $this->filename ); //open file try { diff --git a/changelog.md b/changelog.md index f8ca5bec..dd0049d5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## Version {next} + - Fix uploading files sent to the media endpoint to S3 + ## Version 0.15.5 (2018-01-21) - Formally bump PHP requirement to 7.2 - Add [a11y.css](https://github.com/ffoodd/a11y.css)