Skip to content

Commit 0f00d84

Browse files
committed
MC-38246: Support by Magento Page Builder
1 parent 0aa1b87 commit 0f00d84

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

app/code/Magento/PageBuilder/Model/ImageContentUploader.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\PageBuilder\Model;
99

10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\MediaStorage\Helper\File\Storage;
1112
use Magento\MediaStorage\Helper\File\Storage\Database;
1213
use Magento\MediaStorage\Model\File\Uploader;
@@ -68,7 +69,7 @@ public function upload($fileName, $fileData, $directoryPath): ?string
6869
{
6970
$this->_file = $this->decodeContent($fileName, $fileData);
7071
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.'));
7273
}
7374
$this->_fileExists = true;
7475
$this->_uploadType = self::SINGLE_STYLE;
@@ -88,7 +89,7 @@ public function upload($fileName, $fileData, $directoryPath): ?string
8889
*/
8990
private function decodeContent($fileName, $fileData): array
9091
{
91-
$tmpFileName = $this->getTmpFileName();
92+
$tmpFileName = uniqid($this->filePrefix, true);
9293
$fileSize = $this->systemTmpDirectory->writeFile($tmpFileName, base64_decode($fileData));
9394

9495
return [
@@ -99,14 +100,4 @@ private function decodeContent($fileName, $fileData): array
99100
'size' => $fileSize,
100101
];
101102
}
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-
}
112103
}

0 commit comments

Comments
 (0)