Deprecation of Duplicate Code Streamlines File Upload Handling in Drupal Core
Drupal core introduces a significant enhancement in file upload processing, deprecating duplicate code for parsing filenames from the content-disposition header by Kim Pepper. The latest change was implemented in version 10.3.0 and continues in the 11.x branch, incorporates a new static method for this purpose. Developers can now utilize the following example code to parse filenames efficiently:
use Symfony\Component\HttpFoundation\Request; $filename = ContentDispositionFilenameParser::parseFilename($request) |
This improvement leads to the deprecation of redundant methods in the REST and JSON API modules, specifically:
1.`\Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader::validateAndParseContentDispositionHeader()`
2.`\Drupal\file\Plugin\rest\resource\FileUploadResource::validateAndParseContentDispositionHeader()`
Module developers are encouraged to adopt this streamlined approach, enhancing the overall efficiency of file upload handling in Drupal core. The deprecation serves to maintain code clarity and reduce redundancy, aligning with Drupal's commitment to codebase cleanliness and developer-friendly practices. Access more information here.