Drupal public (public://) stream wrapper class.
Provides support for storing publicly accessible files with the Drupal file interface.
Hierarchy
Properties
| Name | Description |
|---|---|
| DrupalLocalStreamWrapper::$context | Stream context resource. |
| DrupalLocalStreamWrapper::$handle | A generic resource handle. |
| DrupalLocalStreamWrapper::$uri | Instance URI (stream). |
Functions & methods
File
- includes/
stream_wrappers.inc, line 766 - Drupal stream wrapper interface.
View source
class DrupalPublicStreamWrapper extends DrupalLocalStreamWrapper {
/**
* Implements abstract public function getDirectoryPath()
*/
public function getDirectoryPath() {
return variable_get('file_public_path', conf_path() . '/files');
}
/**
* Overrides getExternalUrl().
*
* Return the HTML URI of a public file.
*/
function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
}
}