Filename property is not updated when a duplicate file is renamed In REST and JSON API file uploads

Created on 21 November 2023, 10 months ago
Updated 14 February 2024, 7 months ago

Problem/Motivation

In πŸ“Œ Refactor FileUploadResource to use FileUploadHandler RTBC we are trying to refactor out duplicate upload code by re-using FileUploadHandler. However, core file field uploads that currently use FileUploadHandler will rename to filename property of a File entity if

  1. There is a security rename
  2. There is an existing file with that name (using EXISTS_RENAME)

e.g. https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/...

// Update the filename with any changes as a result of security or renaming
// due to an existing file.
$file->setFilename($this->fileSystem->basename($file->getFileUri()));

However, FileUploadResource and TemporaryJsonapiFileFieldUploader only change the filename property of a File entity if

  1. There is a security rename

Steps to reproduce

Proposed resolution

Update FileUploadResource and TemporaryJsonapiFileFieldUploader to match the behaviour of the core file field upload. See#2.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

11.0 πŸ”₯

Component
RESTΒ  β†’

Last updated 6 days ago

Created by

πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024