File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
AdobeStockImage/Model/Storage Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -38,23 +38,28 @@ class Save
3838 * @var IsPathExcludedInterface
3939 */
4040 private $ isPathExcluded ;
41+
42+ /**
43+ * @var int|null
44+ */
4145 private $ maxFileLength ;
4246
4347 /**
4448 * @param Filesystem $filesystem
4549 * @param Https $driver
4650 * @param IsPathExcludedInterface $isPathExcluded
51+ * @param int|null $maxFileLength
4752 */
4853 public function __construct (
4954 Filesystem $ filesystem ,
5055 Https $ driver ,
5156 IsPathExcludedInterface $ isPathExcluded ,
52- $ maxFileLength
57+ int $ maxFileLength = null
5358 ) {
5459 $ this ->filesystem = $ filesystem ;
5560 $ this ->driver = $ driver ;
5661 $ this ->isPathExcluded = $ isPathExcluded ;
57- $ this ->maxFileLength = $ maxFileLength ;
62+ $ this ->maxFileLength = $ maxFileLength ?: 255 ;
5863 }
5964
6065 /**
@@ -69,12 +74,8 @@ public function __construct(
6974 */
7075 public function execute (string $ imageUrl , string $ destinationPath , bool $ allowOverwrite = false ): void
7176 {
72- $ maxFilenameLength = $ this ->maxFileLength ;
73-
74- if (strlen ($ destinationPath ) > $ maxFilenameLength ) {
75- throw new \InputException (
76- __ ('Destination Path is too long; must be %1 characters or less ' , $ maxFilenameLength )
77- );
77+ if (strlen ($ destinationPath ) > $ this ->maxFileLength ) {
78+ throw new LocalizedException (__ ('Destination Path is too long; must be %1 characters or less ' , $ this ->maxFileLength ));
7879 }
7980
8081 $ mediaDirectory = $ this ->filesystem ->getDirectoryWrite (DirectoryList::MEDIA );
You can’t perform that action at this time.
0 commit comments