0

I am using Flysystem module with flysystem_dropbox and flysystem_s3 for storage. I have configured the schemes in settings.php as described in readme.txt files of the modules.

Now when I am syncing the files from local to dropbox or local to s3 the sync process is working fine but if I try to store file directly from a node add form to dropbox or s3 its not working. I am getting the following errors in recent log messages link

Dropbox error :

The upload directory dropboxexample:// for the file field field_dropbox_file could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.

S3 error :

Aws\S3\Exception\S3Exception: Error executing "PutObject" on "https://s3-eu-west-1.amazonaws.com/drupal8test/&quot;; AWS HTTP error: Client error response [url] https://s3-eu-west-1.amazonaws.com/drupal8test/ [status code] 400 [reason phrase] Bad Request IllegalLocationConstraintException (client): The unspecified location constraint is incompatible for the region specific endpoint this request was sent to. - <?xml version="1.0" encoding="UTF-8"?> <Error><Code>IllegalLocationConstraintException</Code><Message>The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.</Message><RequestId>A0EFF7B64110C2C5</RequestId><HostId>hze5fRf4JLZYsWLrlT5djroRwL/LrxWgzFX9qU5tP+riDfBeYNn900z36HtwktejaqckD2Gwhss=</HostId></Error> in Aws\WrappedHttpHandler->parseError() (line 153 of /var/www/html/drupal8/core/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php).

My scheme configuration is like below:

$schemes = [
  'dropboxexample' => [
    'driver' => 'dropbox',
    'config' => [
      'token' => '[my-token]',
      'client_id' => '[my login email id]',
    ],
  ],
  's3example' => [
    'type' => 's3',
    'driver' => 's3',
    'config' => [
      'key'    => '[my-access-key]',
      'secret' => '[my-secret-key]',
      'region' => 'eu-west-1',
      'bucket' => '[bucket-name]',
      'cname' => '[bucket-url]',
    ],
  ],
  'localexample' => [
    'driver' => 'local',
    'config' => [
      'root' => '/var/www/html/drupal8/sites/default/files',
    ],

    'cache' => FALSE, 
    'replicate' => 'dropboxexample',

    'serve_js' => TRUE,
    'serve_css' => TRUE,
  ]
];

$settings['flysystem'] = $schemes;

So can anyone tell me if I am missing some configuration settings or something else?

1 Answers1

0

I have the same problem, seems is your AWS policy, you need to review S3 policy and then use the simulator to check it would work at least at Amazon S3. also I opened a ticket with this issue if you want to follow

Drupal issue https://www.drupal.org/node/2666260

You problem is the region, it need to be set just like

//|Region name               |Region id      |
//|:-------------------------|:--------------|
// |US East (N. Virginia)     |us-east-1      |
// |US West (N. California)   |us-west-1      |
// |US West (Oregon)          |us-west-2      |
// |EU (Ireland)              |eu-west-1      |
// |EU (Frankfurt)            |eu-central-1   |
// |Asia Pacific (Tokyo)      |ap-northeast-1 |
// |Asia Pacific (Seoul)      |ap-northeast-2 |
// |Asia Pacific (Singapore)  |ap-southeast-1 |
// |Asia Pacific (Sydney)     |ap-southeast-2 |
// |South America (Sao Paulo) |sa-east-1      |

$schemes = [
  's3' => [
    'driver' => 's3',
    'config' => [
      'key'    => '[your key]',
      'secret' => '[your secret]',
      'region' => '[aws-region-id]',
      'bucket' => '[bucket-name]',

  // Optional configuration settings.

  'options' => [
    'ACL' => 'public-read',
    'StorageClass' => 'REDUCED_REDUNDANCY',
  ],

  'protocol' => 'https',             // Will be autodetected based on the current request.

  'prefix' => 'an/optional/prefix',  // Directory prefix for all uploaded/viewed files.

  'cname' => 'static.example.com',   // A cname that resolves to your bucket. Used for URL generation.
],

'cache' => TRUE, // Creates a metadata cache to speed up lookups.

], ];

$settings['flysystem'] = $schemes;

Gucho Ca
  • 690
  • 6
  • 17