You are here

public function S3FileSchemeHandler::addAttributes in Acquia Content Hub 8.2

Throws

\Exception

Overrides FileSchemeHandlerInterface::addAttributes

File

modules/acquia_contenthub_s3/src/Plugin/FileSchemeHandler/S3FileSchemeHandler.php, line 90

Class

S3FileSchemeHandler
S3 file scheme handler.

Namespace

Drupal\acquia_contenthub_s3\Plugin\FileSchemeHandler

Code

public function addAttributes(CDFObject $object, FileInterface $file) {
  $uri = $file
    ->getFileUri();
  $streamWrapper = $this->streamWrapperManager
    ->getViaUri($uri);
  $url = $streamWrapper
    ->getExternalUrl();
  $object
    ->addAttribute('file_scheme', CDFAttribute::TYPE_STRING, 's3');
  $object
    ->addAttribute('file_location', CDFAttribute::TYPE_STRING, $url);
  $object
    ->addAttribute('file_uri', CDFAttribute::TYPE_STRING, $uri);
  $object
    ->addAttribute('ach_s3_bucket', CDFAttribute::TYPE_STRING, $this->s3fsConfig
    ->get('bucket'));
  $object
    ->addAttribute('ach_s3_source', CDFAttribute::TYPE_STRING, $this->s3fsConfig
    ->get('root_folder'));
}