Created
August 27, 2021 21:37
-
-
Save acidjazz/8572c7651b1cdf9ad426f2cfca5fbec5 to your computer and use it in GitHub Desktop.
store a file to s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function store(Request $request): Response|JsonResponse | |
{ | |
$this | |
->option('file', 'required|file|max:10000000') | |
->option('type', 'nullable|in:' . Image::ABLES) | |
->option('id', 'nullable') | |
->verify(); | |
/** @var UploadedFile $file */ | |
$file = $request->file; | |
$fileName = $file->storePublicly(''); | |
return $this->success('image.uploaded', [], [ | |
'url' => 'https://' . config('filesystems.disks.s3.bucket') . '.s3.amazonaws.com/' . $fileName, | |
'file' => $fileName, | |
'name' => $file->getClientOriginalName(), | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment