You are here

class TemporaryStream in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php \Drupal\Core\StreamWrapper\TemporaryStream
  2. 9 core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php \Drupal\Core\StreamWrapper\TemporaryStream

Defines a Drupal temporary (temporary://) stream wrapper class.

Provides support for storing temporarily accessible files with the Drupal file interface.

Hierarchy

Expanded class hierarchy of TemporaryStream

1 string reference to 'TemporaryStream'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses TemporaryStream
stream_wrapper.temporary in core/core.services.yml
Drupal\Core\StreamWrapper\TemporaryStream

File

core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php, line 13

Namespace

Drupal\Core\StreamWrapper
View source
class TemporaryStream extends LocalStream {

  /**
   * {@inheritdoc}
   */
  public static function getType() {
    return StreamWrapperInterface::LOCAL_HIDDEN;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return t('Temporary files');
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return t('Temporary local files for upload and previews.');
  }

  /**
   * {@inheritdoc}
   */
  public function getDirectoryPath() {
    return \Drupal::service('file_system')
      ->getTempDirectory();
  }

  /**
   * {@inheritdoc}
   */
  public function getExternalUrl() {
    $path = str_replace('\\', '/', $this
      ->getTarget());
    return Url::fromRoute('system.temporary', [], [
      'absolute' => TRUE,
      'query' => [
        'file' => $path,
      ],
    ])
      ->toString();
  }

}

Members