You are here

protected function FileUploadResource::getUploadLocation in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::getUploadLocation()

Determines the URI for a file field.

Parameters

array $settings: The array of field settings.

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.

1 call to FileUploadResource::getUploadLocation()
FileUploadResource::post in core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
Creates a file from an endpoint.

File

core/modules/file/src/Plugin/rest/resource/FileUploadResource.php, line 506

Class

FileUploadResource
File upload resource.

Namespace

Drupal\file\Plugin\rest\resource

Code

protected function getUploadLocation(array $settings) {
  $destination = trim($settings['file_directory'], '/');

  // Replace tokens. As the tokens might contain HTML we convert it to plain
  // text.
  $destination = PlainTextOutput::renderFromHtml($this->token
    ->replace($destination, []));
  return $settings['uri_scheme'] . '://' . $destination;
}