File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
app/code/Magento/ImportExport/Model
dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -568,9 +568,15 @@ public function uploadSource()
568
568
$ entity = $ this ->getEntity ();
569
569
/** @var $uploader Uploader */
570
570
$ uploader = $ this ->_uploaderFactory ->create (['fileId ' => self ::FIELD_NAME_SOURCE_FILE ]);
571
+ $ uploader ->setAllowedExtensions (['csv ' , 'zip ' ]);
571
572
$ uploader ->skipDbProcessing (true );
572
573
$ fileName = $ this ->random ->getRandomString (32 ) . '. ' . $ uploader ->getFileExtension ();
573
- $ result = $ uploader ->save ($ this ->getWorkingDir (), $ fileName );
574
+ try {
575
+ $ result = $ uploader ->save ($ this ->getWorkingDir (), $ fileName );
576
+ } catch (\Exception $ e ) {
577
+ throw new LocalizedException (__ ('The file cannot be uploaded. ' ));
578
+ }
579
+
574
580
// phpcs:disable Magento2.Functions.DiscouragedFunction.Discouraged
575
581
$ extension = pathinfo ($ result ['file ' ], PATHINFO_EXTENSION );
576
582
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ public function validationDataProvider(): array
93
93
[
94
94
'file_name ' => 'test.txt ' ,
95
95
'mime-type ' => 'text/csv ' ,
96
- 'message ' => '\' txt \' file extension is not supported ' ,
96
+ 'message ' => 'The file cannot be uploaded. ' ,
97
97
'delimiter ' => ', ' ,
98
98
],
99
99
[
You can’t perform that action at this time.
0 commit comments