class S3Adapter in Flysystem - S3 2.0.x
Same name and namespace in other branches
- 8 src/Flysystem/Adapter/S3Adapter.php \Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter
Overrides methods so it works with Drupal.
Hierarchy
- class \Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter extends \League\Flysystem\AwsS3v3\AwsS3Adapter
Expanded class hierarchy of S3Adapter
File
- src/
Flysystem/ Adapter/ S3Adapter.php, line 14
Namespace
Drupal\flysystem_s3\Flysystem\AdapterView source
class S3Adapter extends AwsS3Adapter {
/**
* {@inheritdoc}
*/
public function has($path) {
$location = $this
->applyPathPrefix($path);
if ($this->s3Client
->doesObjectExist($this->bucket, $location, $this->options)) {
return TRUE;
}
if ($this->s3Client
->doesObjectExist($this->bucket, $location . '/') === TRUE) {
return TRUE;
}
else {
return $this
->doesDirectoryExist($location);
}
}
/**
* {@inheritdoc}
*/
public function getMetadata($path) {
$metadata = parent::getMetadata($path);
if ($metadata === FALSE) {
return [
'type' => 'dir',
'path' => $path,
'timestamp' => \Drupal::time()
->getRequestTime(),
'visibility' => AdapterInterface::VISIBILITY_PUBLIC,
];
}
return $metadata;
}
/**
* {@inheritdoc}
*/
protected function upload($path, $body, Config $config) {
$key = $this
->applyPathPrefix($path);
$options = $this
->getOptionsFromConfig($config);
$acl = isset($options['ACL']) ? $options['ACL'] : 'private';
if (!isset($options['ContentType'])) {
if (is_string($body)) {
$options['ContentType'] = Util::guessMimeType($path, $body);
}
else {
$options['ContentType'] = MimeType::detectByFilename($path);
}
}
if (!isset($options['ContentLength'])) {
$options['ContentLength'] = is_string($body) ? Util::contentSize($body) : Util::getStreamSize($body);
}
$this->s3Client
->upload($this->bucket, $key, $body, $acl, [
'params' => $options,
]);
return $this
->normalizeResponse($options, $key);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
S3Adapter:: |
public | function | ||
S3Adapter:: |
public | function | ||
S3Adapter:: |
protected | function |