File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
AdobeStockImage/Model/Storage Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 2020 */
2121class Save
2222{
23+ private const MAX_LENGTH = 255 ;
24+
2325 /**
2426 * @var Filesystem
2527 */
@@ -49,12 +51,19 @@ public function __construct(
4951 * @param string $imageUrl
5052 * @param string $destinationPath
5153 * @return string
52- * @throws AlreadyExistsException
54+ * @throws AlreadyExistsException | InvalidArgumentException
5355 * @throws FileSystemException
5456 */
5557 public function execute (string $ imageUrl , string $ destinationPath = '' ) : string
5658 {
5759 $ mediaDirectory = $ this ->filesystem ->getDirectoryWrite (DirectoryList::MEDIA );
60+ $ maxFilenameLength = self ::MAX_LENGTH ;
61+
62+ if (strlen ($ destinationPath ) > $ maxFilenameLength ) {
63+ throw new \LengthException (
64+ __ ('Destination path is too long; must be %1 characters or less ' , $ maxFilenameLength )
65+ );
66+ }
5867
5968 if ($ mediaDirectory ->isExist ($ destinationPath )) {
6069 throw new AlreadyExistsException (__ ('Image with the same file name already exits. ' ));
You can’t perform that action at this time.
0 commit comments