- $storageType = config('filesystems.attachments');
-
- // Change to our secure-attachment disk if any of the local options
- // are used to prevent escaping that location.
- if ($storageType === 'local' || $storageType === 'local_secure') {
- $storageType = 'local_secure_attachments';
- }
-
- return $storageType;
- }
-
- /**
- * Change the originally provided path to fit any disk-specific requirements.
- * This also ensures the path is kept to the expected root folders.
- */
- protected function adjustPathForStorageDisk(string $path): string
- {
- $path = Util::normalizePath(str_replace('uploads/files/', '', $path));
-
- if ($this->getStorageDiskName() === 'local_secure_attachments') {
- return $path;
- }
-
- return 'uploads/files/' . $path;
- }
-
- /**
- * Get an attachment from storage.
- *
- * @throws FileNotFoundException
- */
- public function getAttachmentFromStorage(Attachment $attachment): string
- {
- return $this->getStorage()->get($this->adjustPathForStorageDisk($attachment->path));