I need help with private files stored at S3 bucket. I have private bucket configured at $settings['flysystem'], but I need somehow say to Drupal, where are stored private files. I expect that I have to configure $settings['file_private_path']. What should be set for file_private_path, if I am using flysystem_s3 as private files folder?

PS: I am using flysystem_s3 2.0.0-rc1. It isn't possible select it as version in issue form.

Comments

siva01 created an issue.

mrconnerton’s picture

On version 2.1.3 I am doing:

$schemes = [];
if ($_ENV['FLYSYSTEM_PRIVATE_S3'] == 'true') {
  $s3_schema = [
    'driver' => 's3',
    'config' => [
      'region' => $_ENV['FLYSYSTEM_PRIVATE_S3_REGION'],
      'bucket' => $_ENV['FLYSYSTEM_PRIVATE_S3_BUCKET'],
    ],
    'options' => [
      'ACL' => 'private',
    ],
    'cache' => TRUE,
  ];

  if (!empty($_ENV['FLYSYSTEM_PRIVATE_S3_KEY'])) {
    $s3_schema['config']['key'] = $_ENV['FLYSYSTEM_PRIVATE_S3_KEY'];
  }

  if (!empty($_ENV['FLYSYSTEM_PRIVATE_S3_SECRET'])) {
    $s3_schema['config']['secret'] = $_ENV['FLYSYSTEM_PRIVATE_S3_SECRET'];
  }

  $schemes['private'] = $s3_schema;
  $settings['file_private_path'] = 'private';

  $settings['stream_wrappers']['private'] = [
    'class' => '\Drupal\flysystem\FlysystemStreamWrapper',
    'config' => [
      'driver' => 'private',
    ],
  ];
}

$settings['flysystem'] = $schemes;

and my .env has

FLYSYSTEM_PRIVATE_S3=false
FLYSYSTEM_PRIVATE_S3_REGION=
FLYSYSTEM_PRIVATE_S3_BUCKET=
FLYSYSTEM_PRIVATE_S3_KEY=
FLYSYSTEM_PRIVATE_S3_SECRET=