public function DrupalAltStreamWrapper::getExternalUrl in Alternative Stream Wrappers 7
Overrides getExternalUrl().
Overrides DrupalStreamWrapperInterface::getExternalUrl
File
- ./
alt_stream_wrappers.module, line 82 - Provides one or more configurable alternative stream wrappers for file storage.
Class
- DrupalAltStreamWrapper
- Drupal alternative stream wrapper class.
Code
public function getExternalUrl() {
$scheme = file_uri_scheme($this->uri);
// What kind of wrapper is this?
$wrappers = file_get_stream_wrappers();
$wrapper = isset($wrappers[$scheme]) ? $wrappers[$scheme] : FALSE;
if ($wrapper) {
if ($wrapper['type'] & STREAM_WRAPPERS_LOCAL_NORMAL) {
// Same as public:// stream wrapper
$path = str_replace('\\', '/', $this
->getTarget());
return $GLOBALS['base_url'] . '/' . self::getDirectoryPath() . '/' . drupal_encode_path($path);
}
else {
// Go through the system module like temporary:// and private://
// In order for this file to be downloadable, a module will have to
// implement hook_file_download() and return headers for this scheme.
$path = str_replace('\\', '/', $this
->getTarget());
return url('system/' . $scheme . '/' . $path, array(
'absolute' => TRUE,
));
}
}
}