Renaming file--file resource breaks the (Core) FileUpload Controller

Created on 9 February 2024, 5 months ago

Problem/Motivation

It worth noted that if we use JSON:API Extras to rename file--file into something else (files for example). The \Drupal\jsonapi\Controller\FileUpload will not work anymore, because this resource Route name is hard-coded in \Drupal\jsonapi\Controller\FileUpload::handleFileUploadForNewResource :

    ...
    // @todo Remove line below in favor of commented line in https://www.drupal.org/project/drupal/issues/2878463.
    $self_link = new Link(new CacheableMetadata(), Url::fromRoute('jsonapi.file--file.individual', ['entity' => $file->uuid()]), 'self');
    /* $self_link = new Link(new CacheableMetadata(), $this->entity->toUrl('jsonapi'), ['self']); */
    $links = new LinkCollection(['self' => $self_link]);
   ...

Steps to reproduce

Rename the resource, and use the JSON:API endpoint to upload a file.

Example : /jsonapi/node/article/{file_field_name}

Proposed resolution

Lock this particular resource name until the @todo in the line above is done.

Remaining tasks

TBD

User interface changes

The "Resource Type" field in the "Edit file--file resource config" Form may be read-only.

πŸ› Bug report
Status

Active

Version

3.24

Component

Code

Created by

πŸ‡«πŸ‡·France mattew

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

Comments & Activities

Production build 0.69.0 2024