Skip to content

Commit 9011f73

Browse files
authored
Merge pull request #573 from SnirCD/patch-1
fix: if private, and not checking existance, use temporaryUrl
2 parents d7f1f9a + 4eee4be commit 9011f73

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/Models/Media.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,21 @@ protected function url(): Attribute
4040
{
4141
return Attribute::make(
4242
get: function () {
43-
if (! config('curator.should_check_exists', true)) {
44-
return Storage::disk($this->disk)->url($this->path);
45-
}
46-
47-
if (Storage::disk($this->disk)->exists($this->path) === false) {
43+
if (config('curator.should_check_exists', true) && Storage::disk($this->disk)->exists($this->path) === false) {
4844
return '';
4945
}
5046

5147
try {
52-
$isPrivate = Storage::disk($this->disk)->getVisibility($this->path) === 'private';
48+
$isPrivate = config('curator.visibility','public') === 'private' || Storage::disk($this->disk)->getVisibility($this->path) === 'private ';
5349
} catch (\Throwable) {
5450
// ACL not supported on Storage Bucket, Laravel only throws exception here so need to be careful.
55-
// so we assume it's private
56-
$isPrivate = config(sprintf('filesystems.disks.%s.visibility', $this->disk)) !== 'public';
51+
// so we assume it's private $isPrivate = config(sprintf('filesystems.disks.%s.visibility', $this->disk)) !== 'public';
5752
}
5853

59-
return $isPrivate ? Storage::disk($this->disk)->temporaryUrl(
60-
$this->path,
61-
now()->addMinutes(5)
62-
) : Storage::disk($this->disk)->url($this->path);
54+
return $isPrivate ? Storage::disk($this->disk)->temporaryUrl(
55+
$this->path,
56+
now()->addMinutes(5)
57+
) : Storage::disk($this->disk)->url($this->path);
6358
},
6459
);
6560
}

0 commit comments

Comments
 (0)