Lottiefiles Unable to save uploaded file

Created on 15 November 2023, 8 months ago
Updated 31 January 2024, 5 months ago

Problem/Motivation

When using the Lottiefiles Field type within a Paragraph entity, there is an issue with the file input. Specifically, the uploaded file is not being saved correctly.

Steps to reproduce

  1. Create a new Paragraph type.
  2. Add a field of the Lottiefiles Field type to this Paragraph.
  3. Create a new node and fill in all required fields.
  4. Use the JSON File upload field to upload a JSON file.
  5. After saving, the system should set the file to permanent and update the Lottiefile URL field with the generated URL. However, this does not occur as expected.

Proposed resolution

The issue seems to be related to the handling of file uploads in the LottiefilesFieldWidget class. The current implementation is as follows:

// If file upload get new value.
    // Check file upload field value.
    $values = $form_state->getValues();
    if (isset($values[$element['#array_parents'][0]][$element['#array_parents'][2]]['file']['fids'][0])) {
      $fid = $values[$element['#array_parents'][0]][$element['#array_parents'][2]]['file']['fids'][0];
      $file_object = File::load($fid);
      $file_object->setPermanent();
      $file_object->save();
      $file_uri = $file_object->getFileUri();
      $uri = Url::fromUri(file_create_url($file_uri))->toString();
      $uri = static::getUserEnteredStringAsUri($uri);
    }

However, I have developed a patch that addresses this issue. This patch aims to ensure that the file is saved correctly and that the Lottiefile URL field is updated with the generated URL upon file upload.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024