Fix uploading files to S3

This commit is contained in:
Jonny Barnes 2018-01-27 21:52:24 +00:00
parent b1929ac65a
commit 7262f6a550
3 changed files with 11 additions and 6 deletions

View file

@ -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;
}

View file

@ -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 {

View file

@ -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)