@@ -42,9 +42,10 @@ public function __construct($files = null, $path = null, $disablePermissionCheck
42
42
/**
43
43
* @param Repository $config
44
44
* @param Image $image
45
+ * @param Filesystem $filesystem
45
46
* @return CommandResult
46
47
*/
47
- public function handle (Repository $ config ,Image $ image )
48
+ public function handle (Repository $ config ,Image $ image, Filesystem $ filesystem )
48
49
{
49
50
// check if user has permission
50
51
if ( ! $ this ->disablePermissionChecking )
@@ -65,11 +66,11 @@ public function handle(Repository $config,Image $image)
65
66
66
67
// save the file
67
68
$ file ->move (
68
- $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this ->normalizePath ( $ path ),
69
+ $ this ->getCurrentFullPath ( $ config , $ path ),
69
70
$ normalizedFileName
70
71
);
71
72
72
- $ filePath = $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this ->normalizePath ( $ path ). ' / ' .$ normalizedFileName ;
73
+ $ filePath = $ this ->getCurrentFullPath ( $ config , $ path ).$ normalizedFileName ;
73
74
$ file_name = pathinfo ($ filePath , PATHINFO_FILENAME );
74
75
$ extension = pathinfo ($ filePath , PATHINFO_EXTENSION );
75
76
@@ -80,11 +81,18 @@ public function handle(Repository $config,Image $image)
80
81
{
81
82
foreach ($ sizes as $ key => $ dimension )
82
83
{
84
+ $ targetDir = $ this ->getCurrentFullPath ($ config ,$ path ).$ key .DIRECTORY_SEPARATOR ;
85
+
86
+ if ( ! $ filesystem ->exists ($ targetDir ) )
87
+ {
88
+ $ filesystem ->makeDirectory ($ this ->normalizePath ($ path ).DIRECTORY_SEPARATOR .$ key .DIRECTORY_SEPARATOR );
89
+ }
90
+
83
91
$ image ::createThumbnail (
84
92
$ filePath ,
85
93
$ dimension [0 ],
86
94
$ dimension [1 ],
87
- $ config -> get ( ' filesystems.disks.local.root ' ). ' / ' . $ this -> normalizePath ( $ path ). ' / ' . $ this -> produceThumbFileName ( $ file_name , $ key , $ extension)
95
+ $ targetDir . $ file_name . ' . ' . $ extension
88
96
);
89
97
}
90
98
}
@@ -121,6 +129,16 @@ protected function produceThumbFileName($file_name, $file_size_name, $file_exten
121
129
return $ file_name .'_ ' .$ file_size_name .'. ' .$ file_extension ;
122
130
}
123
131
132
+ /**
133
+ * @param Repository $config
134
+ * @param string $path
135
+ * @return string
136
+ */
137
+ protected function getCurrentFullPath ($ config , $ path )
138
+ {
139
+ return $ config ->get ('filesystems.disks.local.root ' ).DIRECTORY_SEPARATOR .$ this ->normalizePath ($ path ).DIRECTORY_SEPARATOR ;
140
+ }
141
+
124
142
/**
125
143
* when uploading a file, we will remove dashes because dashes are use in UI as size convention
126
144
*
0 commit comments