File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -39,19 +39,27 @@ class Save
3939 */
4040 private $ isPathExcluded ;
4141
42+ /**
43+ * @var int|null
44+ */
45+ private $ maxFileLength ;
46+
4247 /**
4348 * @param Filesystem $filesystem
4449 * @param Https $driver
4550 * @param IsPathExcludedInterface $isPathExcluded
51+ * @param int|null $maxFileLength
4652 */
4753 public function __construct (
4854 Filesystem $ filesystem ,
4955 Https $ driver ,
50- IsPathExcludedInterface $ isPathExcluded
56+ IsPathExcludedInterface $ isPathExcluded ,
57+ int $ maxFileLength = null
5158 ) {
5259 $ this ->filesystem = $ filesystem ;
5360 $ this ->driver = $ driver ;
5461 $ this ->isPathExcluded = $ isPathExcluded ;
62+ $ this ->maxFileLength = $ maxFileLength ?: 255 ;
5563 }
5664
5765 /**
@@ -66,6 +74,10 @@ public function __construct(
6674 */
6775 public function execute (string $ imageUrl , string $ destinationPath , bool $ allowOverwrite = false ): void
6876 {
77+ if (strlen ($ destinationPath ) > $ this ->maxFileLength ) {
78+ throw new LocalizedException (__ ('Destination Path is too long; must be %1 characters or less ' , $ this ->maxFileLength ));
79+ }
80+
6981 $ mediaDirectory = $ this ->filesystem ->getDirectoryWrite (DirectoryList::MEDIA );
7082
7183 if ($ this ->isPathExcluded ->execute ($ destinationPath )) {
Original file line number Diff line number Diff line change 3636 <type name =" Magento\AdobeStockImage\Model\Storage\Save" >
3737 <arguments >
3838 <argument name =" driver" xsi : type =" object" >Magento\Framework\Filesystem\Driver\Https</argument >
39+ <argument name =" maxFileLength" xsi : type =" number" >255</argument >
3940 </arguments >
4041 </type >
4142 <type name =" Magento\AdobeStockImage\Model\GetRelatedImages" >
You can’t perform that action at this time.
0 commit comments