File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ public function getPath(): string
4343 return $ this ->disk ->getDriver ()->getAdapter ()->getPathPrefix ();
4444 }
4545
46+ public function createDirectory (string $ path )
47+ {
48+ return $ this ->disk ->makeDirectory ($ path );
49+ }
50+
4651 public function __call ($ method , $ parameters )
4752 {
4853 return call_user_func_array ([$ this ->disk , $ method ], $ parameters );
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ public function save(string $path): Media
5555
5656 $ destinationPath = $ this ->getDestinationPathForSaving ($ file );
5757
58+ $ this ->createDestinationPathForSaving ($ file );
59+
5860 $ this ->{$ this ->saveMethod }($ destinationPath );
5961
6062 if (!$ this ->getDisk ()->isLocal ()) {
@@ -80,6 +82,17 @@ private function getDestinationPathForSaving(File $file): string
8082 return $ file ->getFullPath ();
8183 }
8284
85+ private function createDestinationPathForSaving (File $ file )
86+ {
87+ if (!$ file ->getDisk ()->isLocal ()) {
88+ return false ;
89+ }
90+
91+ $ directory = pathinfo ($ file ->getPath ())['dirname ' ];
92+
93+ return $ file ->getDisk ()->createDirectory ($ directory );
94+ }
95+
8396 private function saveAudioOrVideo (string $ fullPath ): MediaExporter
8497 {
8598 $ this ->media ->save ($ this ->getFormat (), $ fullPath );
You can’t perform that action at this time.
0 commit comments