public function AmazonS3StreamWrapper::__construct in AmazonS3 7
Object constructor.
1 call to AmazonS3StreamWrapper::__construct()
- AmazonS3StreamWrapper::assertConstructorCalled in ./
AmazonS3StreamWrapper.inc - Assert that the constructor has been called, call it if not.
File
- ./
AmazonS3StreamWrapper.inc, line 125 - Drupal stream wrapper implementation for Amazon S3
Class
- AmazonS3StreamWrapper
- @file Drupal stream wrapper implementation for Amazon S3
Code
public function __construct() {
$this->hostname = variable_get('amazons3_hostname', '');
$this->bucket = $bucket = variable_get('amazons3_bucket', '');
// CNAME support for customising S3 URLs.
if (variable_get('amazons3_cname', 0)) {
$domain = variable_get('amazons3_domain', '');
if (strlen($domain) > 0) {
$this->domain = $domain;
}
else {
$this->domain = $this->bucket;
}
$this->cloudfront = variable_get('amazons3_cloudfront', TRUE);
}
else {
$this->domain = $this->bucket . '.s3.amazonaws.com';
}
// Check whether local file caching is turned on.
if (variable_get('amazons3_cache', TRUE)) {
$this->caching = TRUE;
}
// HTTPS list.
$https = explode("\n", variable_get('amazons3_https', ''));
$https = array_map('trim', $https);
$https = array_filter($https, 'strlen');
$this->https = $https;
// Torrent list.
$torrents = explode("\n", variable_get('amazons3_torrents', ''));
$torrents = array_map('trim', $torrents);
$torrents = array_filter($torrents, 'strlen');
$this->torrents = $torrents;
// Presigned url-list.
$presigned_urls = explode("\n", variable_get('amazons3_presigned_urls', ''));
$presigned_urls = array_map('trim', $presigned_urls);
$presigned_urls = array_filter($presigned_urls, 'strlen');
$this->presignedUrls = array();
foreach ($presigned_urls as $presigned_url) {
// Check for an explicit key.
$matches = array();
if (preg_match('/(.*)\\|(.*)/', $presigned_url, $matches)) {
$this->presignedUrls[$matches[2]] = $matches[1];
}
else {
$this->presignedUrls[$presigned_url] = 60;
}
}
// Force "save as" list.
$saveas = explode("\n", variable_get('amazons3_saveas', ''));
$saveas = array_map('trim', $saveas);
$saveas = array_filter($saveas, 'strlen');
$this->saveAs = $saveas;
// Reduced Redundancy Storage.
$rrs = explode("\n", variable_get('amazons3_rrs', ''));
$rrs = array_map('trim', $rrs);
$rrs = array_filter($rrs, 'strlen');
$this->rrs = $rrs;
}