protected function S3fsStreamWrapper::convertUriToKeyedPath in S3 File System 7.3
Converts a Drupal URI path into what is expected to be stored in S3.
Parameters
$uri: An appropriate URI formatted like 'protocol://path'.
bool $prepend_bucket: Whether to prepend the bucket name. S3's stream wrapper requires this for some functions.
Return value
string A converted string ready for S3 to process it.
6 calls to S3fsStreamWrapper::convertUriToKeyedPath()
- S3fsStreamWrapper::getCommandParams in ./
S3fsStreamWrapper.inc - Return bucket and key for a command array.
- S3fsStreamWrapper::rename in ./
S3fsStreamWrapper.inc - S3fsStreamWrapper::rmdir in ./
S3fsStreamWrapper.inc - Support for rmdir().
- S3fsStreamWrapper::stream_flush in ./
S3fsStreamWrapper.inc - Support for fflush(). Flush current cached stream data to a file in S3.
- S3fsStreamWrapper::stream_open in ./
S3fsStreamWrapper.inc - Support for fopen(), file_get_contents(), file_put_contents() etc.
File
- ./
S3fsStreamWrapper.inc, line 1139 - Drupal stream wrapper implementation for S3 File System.
Class
- S3fsStreamWrapper
- The stream wrapper class.
Code
protected function convertUriToKeyedPath($uri, $prepend_bucket = TRUE) {
// Remove the protocol
$parts = explode('://', $uri);
if (!empty($parts[1])) {
// public:// file are all placed in the s3fs_public_folder.
$public_folder = !empty($this->config['public_folder']) ? $this->config['public_folder'] : 's3fs-public';
$private_folder = !empty($this->config['private_folder']) ? $this->config['private_folder'] : 's3fs-private';
if (file_uri_scheme($uri) == 'public') {
$parts[1] = "{$public_folder}/{$parts[1]}";
}
elseif (file_uri_scheme($uri) == 'private') {
$parts[1] = "{$private_folder}/{$parts[1]}";
}
// If it's set, all files are placed in the root folder.
if (!empty($this->config['root_folder'])) {
$parts[1] = "{$this->config['root_folder']}/{$parts[1]}";
}
// Prepend the uri with a bucket since AWS SDK expects this.
if ($prepend_bucket) {
$parts[1] = $this->config['bucket'] . '/' . $parts[1];
}
}
// Set protocol to S3 so AWS stream wrapper works correctly.
$parts[0] = 's3';
return implode('://', $parts);
}