protected function S3Adapter::upload in Flysystem - S3 8
Same name and namespace in other branches
- 2.0.x src/Flysystem/Adapter/S3Adapter.php \Drupal\flysystem_s3\Flysystem\Adapter\S3Adapter::upload()
File
- src/
Flysystem/ Adapter/ S3Adapter.php, line 53
Class
- S3Adapter
- Overrides methods so it works with Drupal.
Namespace
Drupal\flysystem_s3\Flysystem\AdapterCode
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);
}