Allow uploading *.lottie files

Created on 21 December 2023, over 1 year ago

When you upload a *.lottie file after you adjusted the file restriction a violation gets raised. Can't we also allow uploading *.lottie files directly?

Feature request
Status

Active

Version

2.0

Component

Code

Created by

leymannx Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @leymannx
  • 🇨🇦Canada franckylfs Montreal

    I confirm that I had the same problem.

    After a simple analysis of the logs, I saw the following error:

    Error: Call to undefined method Drupal\media_entity_lottie\Plugin\Validation\Constraint\LottieFileConstraintValidator::addViolation() in Drupal\media_entity_lottie\Plugin\Validation\Constraint\LottieFileConstraintValidator->validate() (line 78 of /var/www/docroot/modules/contrib/media_entity_lottie/src/Plugin/Validation/Constraint/LottieFileConstraintValidator.php).
    

    I analyzed the code and it appears there was a code error originally. You can see in the following code that the call to addViolation is duplicated, in addition to being incorrect on the first line. So, removing the first line completely fixes this problem while maintaining the original functionality.

    if (json_last_error() !== JSON_ERROR_NONE) {
      $this->addViolation($constraint->notValid);
      $this->context->addViolation($constraint->notValid, ['%value' => $fileName]);
      return;
    }

    However, this doesn't solve the problem because the lottie.js library then gives the following error visible in the browser console:

    Uncaught InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json').
    at t (lottie.js:1157:25)

    I tried with different .lottie files and I still get the same error.

    Any other ideas?

Production build 0.71.5 2024