protected function S3fsStream::convertMetadata in S3 File System 8.2
Convert file metadata returned from S3 into a metadata cache array.
Parameters
string $uri: The uri of the resource.
array $s3_metadata: An array containing the collective metadata for the object in S3. The caller may send an empty array here to indicate that the returned metadata should represent a directory.
Return value
array A file metadata cache array.
3 calls to S3fsStream::convertMetadata()
- S3fsStream::mkdir in src/
StreamWrapper/ S3fsStream.php - Support for mkdir().
- S3fsStream::_get_metadata_from_s3 in src/
StreamWrapper/ S3fsStream.php - Returns the converted metadata for an object in S3.
- S3fsStream::_s3fs_get_object in src/
StreamWrapper/ S3fsStream.php - Try to fetch an object from the metadata cache.
File
- src/
StreamWrapper/ S3fsStream.php, line 1622
Class
- S3fsStream
- Defines a Drupal s3fs (s3fs://) stream wrapper class.
Namespace
Drupal\s3fs\StreamWrapperCode
protected function convertMetadata($uri, $s3_metadata) {
// Need to fill in a default value for everything, so that DB calls
// won't complain about missing fields.
$metadata = [
'uri' => $uri,
'filesize' => 0,
'timestamp' => REQUEST_TIME,
'dir' => 0,
'version' => '',
];
if (empty($s3_metadata)) {
// The caller wants directory metadata.
$metadata['dir'] = 1;
}
else {
// The filesize value can come from either the Size or ContentLength
// attribute, depending on which AWS API call built $s3_metadata.
if (isset($s3_metadata['ContentLength'])) {
$metadata['filesize'] = $s3_metadata['ContentLength'];
}
else {
if (isset($s3_metadata['Size'])) {
$metadata['filesize'] = $s3_metadata['Size'];
}
}
if (isset($s3_metadata['LastModified'])) {
$metadata['timestamp'] = date('U', strtotime($s3_metadata['LastModified']));
}
if (isset($s3_metadata['VersionId'])) {
$metadata['version'] = $s3_metadata['VersionId'];
}
}
return $metadata;
}