- $uploadFileName = Str::random(16) . '.' . $uploadedFile->getClientOriginalExtension();
- while ($storage->exists($this->adjustPathForStorageDisk($basePath . $uploadFileName))) {
- $uploadFileName = Str::random(3) . $uploadFileName;
- }
-
- $attachmentPath = $basePath . $uploadFileName;
-
- try {
- $storage->put($this->adjustPathForStorageDisk($attachmentPath), $attachmentData);
- } catch (Exception $e) {
- Log::error('Error when attempting file upload:' . $e->getMessage());
-
- throw new FileUploadException(trans('errors.path_not_writable', ['filePath' => $attachmentPath]));
- }
+ return $this->storage->uploadFile(
+ $uploadedFile,
+ $basePath,
+ $uploadedFile->getClientOriginalExtension(),
+ ''
+ );
+ }