Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
foundation
/
src
/
Files
/
S3
:
S3SimpleUploadController.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Common\Files\S3; use Carbon\Carbon; use Common\Core\BaseController; use Common\Files\Actions\ValidateFileUpload; use Common\Files\S3\InteractsWithS3Api; class S3SimpleUploadController extends BaseController { use InteractsWithS3Api; public function __construct() { $this->middleware('auth'); } public function presignPost() { $fileKey = $this->buildFileKey(); $errors = app(ValidateFileUpload::class)->execute(request()->all()); if ($errors) { abort(422, $errors->first()); } $command = $this->getClient()->getCommand('PutObject', [ 'Bucket' => $this->getBucket(), 'ContentType' => request()->input('mime'), 'Key' => $fileKey, 'ACL' => $this->getAcl(), ]); $uri = $this->getClient() ->createPresignedRequest($command, Carbon::now()->addHour()) ->getUri(); return $this->success([ 'url' => $uri, 'key' => $fileKey, 'acl' => $this->getAcl(), ]); } }