function FileUploadResource::getUploadLocation

Same name in other branches
  1. 8.9.x core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::getUploadLocation()
  2. 10 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 527

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.