-
- /**
- * Save image data for the given path in the public space, if possible,
- * for the provided storage mechanism.
- */
- public function storeInPublicSpace(StorageDisk $storage, string $path, string $data): void
- {
- $storage->put($path, $data);
-
- // Set visibility when a non-AWS-s3, s3-like storage option is in use.
- // Done since this call can break s3-like services but desired for other image stores.
- // Attempting to set ACL during above put request requires different permissions
- // hence would technically be a breaking change for actual s3 usage.
- if (!$this->isS3Like()) {
- $storage->setVisibility($path, 'public');
- }
- }
-
- /**
- * Check if the image storage in use is an S3-like (but not likely S3) external system.
- */
- protected function isS3Like(): bool
- {
- $usingS3 = strtolower(config('filesystems.images')) === 's3';
- return $usingS3 && !is_null(config('filesystems.disks.s3.endpoint'));
- }