+ parent::__construct($fileSystem);
+ }
+
+ /**
+ * Get the storage that will be used for storing images.
+ * @param string $type
+ * @return \Illuminate\Contracts\Filesystem\Filesystem
+ */
+ protected function getStorage($type = '')
+ {
+ $storageType = config('filesystems.default');
+
+ // Override default location if set to local public to ensure not visible.
+ if ($type === 'system' && $storageType === 'local_secure') {
+ $storageType = 'local';
+ }
+
+ return $this->fileSystem->disk($storageType);
+ }
+
+ /**
+ * Saves a new image from an upload.
+ * @param UploadedFile $uploadedFile
+ * @param string $type
+ * @param int $uploadedTo
+ * @return mixed
+ * @throws ImageUploadException
+ */
+ public function saveNewFromUpload(UploadedFile $uploadedFile, $type, $uploadedTo = 0)
+ {
+ $imageName = $uploadedFile->getClientOriginalName();
+ $imageData = file_get_contents($uploadedFile->getRealPath());
+ return $this->saveNew($imageName, $imageData, $type, $uploadedTo);
+ }
+
+ /**
+ * Save a new image from a uri-encoded base64 string of data.
+ * @param string $base64Uri
+ * @param string $name
+ * @param string $type
+ * @param int $uploadedTo
+ * @return Image
+ * @throws ImageUploadException
+ */
+ public function saveNewFromBase64Uri(string $base64Uri, string $name, string $type, $uploadedTo = 0)
+ {
+ $splitData = explode(';base64,', $base64Uri);
+ if (count($splitData) < 2) {
+ throw new ImageUploadException("Invalid base64 image data provided");
+ }
+ $data = base64_decode($splitData[1]);
+ return $this->saveNew($name, $data, $type, $uploadedTo);