Skip to content

Commit 846928e

Browse files
Move files to public disk in local environment
1 parent d6983d4 commit 846928e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Support/Thumbnails/LocalThumbnail.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ private function generateThumbnail(string $sourceDisk, string $sourceRelPath, st
8888

8989
public function download(): ?string
9090
{
91-
return $this->storage->disk($this->mediaModel->disk)->url($this->mediaModel->file_name);
91+
$filesDisk = $this->storage->disk('public');
92+
93+
if (!$filesDisk->exists($this->mediaModel->file_name)) {
94+
// Create files directories if needed
95+
if (!$filesDisk->exists(dirname($this->mediaModel->file_name))) {
96+
$filesDisk->makeDirectory(dirname($this->mediaModel->file_name));
97+
}
98+
99+
try{
100+
$filesDisk->put($this->mediaModel->file_name, $this->storage->disk($this->mediaModel->disk)->get($this->mediaModel->file_name));
101+
}catch (FileNotFoundException|DecoderException) {
102+
return null;
103+
}
104+
}
105+
106+
return $this->storage->disk("public")->url($this->mediaModel->file_name);
92107
}
93108
}

0 commit comments

Comments
 (0)