Deprecation of Duplicate Code Streamlines File Upload Handling in Drupal Core

Latest Update
rawpixel.com / Freepik
Comment

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.

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please let us know in the comments below and we will try to address the issue as best we can.

Advertisement Here

Upcoming Events

Latest Opportunities

Advertisement Here