Provide a method for FileUploads to be moved in UploadedFileInterface

Created on 15 April 2024, 7 months ago
Updated 16 April 2024, 7 months ago

Problem/Motivation

Currently, FileUploadHandler provides a method \Drupal\file\Upload\FileUploadHandler::moveUploadedFile() to allow an extension point to move both FormUploadedFiles and yet to be implemented InputStreamUploadedFiles that will be used to DRY up file upload handling for both form file uploads and JSON API and REST file uploads.

The todo reads:

   * @todo Allows a sub-class to override this method in order to handle
   * raw file uploads in https://www.drupal.org/project/drupal/issues/2940383.
  

FormUploadedFile is required to use \Drupal\Core\File\FileSystemInterface::moveUploadedFile() in order to support PHP's standard move_uploaded_file() method.

The proposed InputStreamUploadedFile cannot use this, and is required to use \Drupal\Core\File\FileSystemInterface::move() instead.

However, since this was proposed as the solution, we have added \Drupal\file\Upload\UploadedFileInterface::validate() to validate file uploads (before they become file entities).

We can follow this pattern for moving file uploads too.

Steps to reproduce

Proposed resolution

Add a new method \Drupal\file\Upload\UploadedFileInterface::moveUploadedFile(FileSystemInterface $fileSystem, string $destination) that allows the implementing class to provide the correct way of moving uploaded files.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Closed: won't fix

Version

11.0 πŸ”₯

Component
File moduleΒ  β†’

Last updated 2 days ago

Created by

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

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024