7
7
8
8
namespace Magento \PageBuilder \Model ;
9
9
10
+ use Magento \Framework \Exception \LocalizedException ;
10
11
use Magento \MediaStorage \Helper \File \Storage ;
11
12
use Magento \MediaStorage \Helper \File \Storage \Database ;
12
13
use Magento \MediaStorage \Model \File \Uploader ;
@@ -68,7 +69,7 @@ public function upload($fileName, $fileData, $directoryPath): ?string
68
69
{
69
70
$ this ->_file = $ this ->decodeContent ($ fileName , $ fileData );
70
71
if (!$ this ->systemTmpDirectory ->isExist ($ this ->_file ['tmp_name ' ])) {
71
- throw new \ InvalidArgumentException ( 'There was an error during file content upload. ' );
72
+ new LocalizedException ( __ ( 'There was an error during file content upload. ' ) );
72
73
}
73
74
$ this ->_fileExists = true ;
74
75
$ this ->_uploadType = self ::SINGLE_STYLE ;
@@ -88,7 +89,7 @@ public function upload($fileName, $fileData, $directoryPath): ?string
88
89
*/
89
90
private function decodeContent ($ fileName , $ fileData ): array
90
91
{
91
- $ tmpFileName = $ this ->getTmpFileName ( );
92
+ $ tmpFileName = uniqid ( $ this ->filePrefix , true );
92
93
$ fileSize = $ this ->systemTmpDirectory ->writeFile ($ tmpFileName , base64_decode ($ fileData ));
93
94
94
95
return [
@@ -99,14 +100,4 @@ private function decodeContent($fileName, $fileData): array
99
100
'size ' => $ fileSize ,
100
101
];
101
102
}
102
-
103
- /**
104
- * Generate temporary file name
105
- *
106
- * @return string
107
- */
108
- private function getTmpFileName (): string
109
- {
110
- return uniqid ($ this ->filePrefix , true );
111
- }
112
103
}
0 commit comments