function FileUploadLocationTrait::getUploadLocation
Same name in other branches
- 10 core/modules/file/src/Upload/FileUploadLocationTrait.php \Drupal\file\Upload\FileUploadLocationTrait::getUploadLocation()
Resolves the file upload location from a file field definition.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition: The file field definition.
Return value
string An un-sanitized file directory URI with tokens replaced. The result of the token replacement is then converted to plain text and returned.
2 calls to FileUploadLocationTrait::getUploadLocation()
- FileUpload::handleFileUploadForResource in core/
modules/ jsonapi/ src/ Controller/ FileUpload.php - Handles JSON:API file upload requests.
- FileUploadResource::post in core/
modules/ file/ src/ Plugin/ rest/ resource/ FileUploadResource.php - Creates a file from an endpoint.
File
-
core/
modules/ file/ src/ Upload/ FileUploadLocationTrait.php, line 25
Class
- FileUploadLocationTrait
- Resolves the file upload location from a file field definition.
Namespace
Drupal\file\UploadCode
public function getUploadLocation(FieldDefinitionInterface $fieldDefinition) : string {
assert(is_a($fieldDefinition->getClass(), FileFieldItemList::class, TRUE));
$fieldItemDataDefinition = FieldItemDataDefinition::create($fieldDefinition);
$fileItem = new FileItem($fieldItemDataDefinition);
return $fileItem->getUploadLocation();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.