Private files stored at S3: How configure $settings['file_private_path']?

Created on 15 July 2020, over 5 years ago
Updated 27 June 2025, 4 months ago

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.

πŸ’¬ Support request
Status

Active

Component

Documentation

Created by

πŸ‡¨πŸ‡ΏCzech Republic siva01

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mrconnerton

    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=
    
Production build 0.71.5 2024