public function AmazonS3StreamWrapper::stream_open in AmazonS3 7
Support for fopen(), file_get_contents(), file_put_contents() etc.
Parameters
string $uri: A string containing the URI to the file to open.
string $mode: The file mode ("r", "wb" etc.).
int $options: A bit mask of STREAM_USE_PATH and STREAM_REPORT_ERRORS.
string $opened_path: A string containing the path actually opened.
Return value
bool Returns TRUE if file was opened successfully.
Overrides StreamWrapperInterface::stream_open
See also
http://php.net/manual/en/streamwrapper.stream-open.php
File
- ./
AmazonS3StreamWrapper.inc, line 425 - Drupal stream wrapper implementation for Amazon S3
Class
- AmazonS3StreamWrapper
- @file Drupal stream wrapper implementation for Amazon S3
Code
public function stream_open($uri, $mode, $options, &$opened_path) {
$this->uri = $uri;
// If this stream is being opened for writing, clear the object buffer.
// Return true as we'll create the object on fflush call.
if (strpbrk($mode, 'wax')) {
$this
->clearBuffer();
$this->write_buffer = TRUE;
return TRUE;
}
$metadata = $this
->_amazons3_get_object($uri, $this->caching);
if ($metadata) {
$this
->clearBuffer();
$this->write_buffer = FALSE;
$this->objectSize = $metadata['filesize'];
return TRUE;
}
return FALSE;
}