@@ -200,21 +200,10 @@ public function moveFileFromTmp($imageName)
200
200
{
201
201
$ baseTmpPath = $ this ->getBaseTmpPath ();
202
202
$ basePath = $ this ->getBasePath ();
203
-
203
+
204
204
$ baseImagePath = $ this ->getFilePath ($ basePath , $ imageName );
205
205
$ baseTmpImagePath = $ this ->getFilePath ($ baseTmpPath , $ imageName );
206
-
207
- $ destinationFileAbsolutePath = $ this ->mediaDirectory ->getAbsolutePath ($ baseImagePath );
208
- $ fileInfo = pathinfo ($ destinationFileAbsolutePath );
209
- if (file_exists ($ destinationFileAbsolutePath )) {
210
- $ index = 1 ;
211
- $ imageName = $ fileInfo ['filename ' ] . '. ' . $ fileInfo ['extension ' ];
212
- while (file_exists ($ fileInfo ['dirname ' ] . '/ ' . $ imageName )) {
213
- $ imageName = $ fileInfo ['filename ' ] . '_ ' . $ index . '. ' . $ fileInfo ['extension ' ];
214
- $ index ++;
215
- }
216
- $ baseImagePath = $ this ->getFilePath ($ basePath , $ imageName );
217
- }
206
+
218
207
try {
219
208
$ this ->coreFileStorageDatabase ->copyFile (
220
209
$ baseTmpImagePath ,
@@ -233,7 +222,7 @@ public function moveFileFromTmp($imageName)
233
222
return $ imageName ;
234
223
}
235
224
236
- /**
225
+ /**
237
226
* Checking file for save and save it to tmp dir
238
227
*
239
228
* @param string $fileId
@@ -244,16 +233,16 @@ public function moveFileFromTmp($imageName)
244
233
*/
245
234
public function saveFileToTmpDir ($ fileId )
246
235
{
247
- $ baseTmpPath = $ this ->getBaseTmpPath ();
236
+ $ baseTmpPath = $ this ->getBaseTmpPath ();
248
237
249
238
/** @var \Magento\MediaStorage\Model\File\Uploader $uploader */
250
239
$ uploader = $ this ->uploaderFactory ->create (['fileId ' => $ fileId ]);
251
240
$ uploader ->setAllowedExtensions ($ this ->getAllowedExtensions ());
252
241
$ uploader ->setAllowRenameFiles (true );
253
242
if (!$ uploader ->checkMimeType ($ this ->allowedMimeTypes )) {
254
243
throw new \Magento \Framework \Exception \LocalizedException (__ ('File validation failed. ' ));
255
- }
256
- $ result = $ uploader ->save ($ this ->mediaDirectory ->getAbsolutePath ($ baseTmpPath ));
244
+ }
245
+ $ result = $ uploader ->save ($ this ->mediaDirectory ->getAbsolutePath ($ baseTmpPath ));
257
246
unset($ result ['path ' ]);
258
247
259
248
if (!$ result ) {
0 commit comments