V8-archive: Amazon S3 Adapter not working

Created on 4 Jul 2019  Â·  11Comments  Â·  Source: directus/v8-archive

Bug Report

I've follow the documentation to install / configure correctly S3 Adapter - Watch the Youtube video related to the previous version and impossible for me to upload a file.

Steps to Reproduce

  1. Follow this documentation : https://docs.directus.io/extensions/storage-adapters.html#using-aws-s3
  2. Create an Amazon S3 Account
  3. Create the S3 Bucket
  4. Create IAM User to get required s3 informations
  5. Grant AmazonS3FullAccess authorization to the user
  6. Edit Bucket Policy as Below (flysystem-aws-s3-v3 documentation)
    { "Version": "2012-10-17", "Id": "Policy1562237059980", "Statement": [ { "Sid": "Stmt1562237050057", "Effect": "Allow", "Principal": "*", "Action": [ "s3:ListBucket", "s3:GetObject", "s3:GetObjectAcl", "s3:PutObject", "s3:PutObjectAcl", "s3:ReplicateObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::orchard-emblem", "arn:aws:s3:::orchard-emblem/*" ] } ] }
  7. Update config inside Directus
  8. Try to upload a file
  9. Always got the same error related to : src/core/Directus/Filesystem/Filesystem.php (No permission to write: ...)

Expected Behavior

Upload a file correctly on S3

Actual Behavior

Always got an error on upload. Think I've miss something in my configuration

Configuration
'storage' => [ 'adapter' => 's3', 'key' => 'AKIA3ONIZBWFZE56QHGO', 'secret' => '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', 'bucket' => 'orchard-emblem', 'version' => 'latest', 'region' => 'us-west-1', 'options' => [ 'ACL' => 'public-read', 'Cache-Control' => 'max-age=604800' ], 'root' => '/stbarths', 'thumb_root' => '/stbarths/thumbnails', 'root_url' => 'https://orchard-emblem.s3-us-west-1.amazonaws.com' ],

Other Context & Screenshots

...

Technical Details

  • Device: Desktop
  • OS: MacOS Mojave 10.14.5 (18F132)
  • Web Server: Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-54-generic x86_64) with Apache/2.4.29 - Digital Ocean Lamp Droplet
  • PHP Version: PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS )
  • Database: libmysql - mysqlnd 5.0.12-dev - 20150407
  • Install Method: Master branch cloned
  • Directus version : v7.6.1 (Latest and correctly working)

Most helpful comment

@hemratna : The only way to make it works regarding your comment is to switch all permissions to "Off" on my bucket as below :

  • Block all public access Off
  • Block public access to buckets and objects granted through new access control lists (ACLs) Off
  • Block public access to buckets and objects granted through any access control lists (ACLs) Off
  • Block public access to buckets and objects granted through new public bucket policies Off
  • Block public and cross-account access to buckets and objects through any public bucket policies Off

All 11 comments

@albanallee
I am getting below error with your Bucket Policy in my bucket.

Policy has invalid resource

Can you give it a try without any Bucket Policy?

By removing the Policy, I've got the same error :/ @hemratna

@hemratna : The only way to make it works regarding your comment is to switch all permissions to "Off" on my bucket as below :

  • Block all public access Off
  • Block public access to buckets and objects granted through new access control lists (ACLs) Off
  • Block public access to buckets and objects granted through any access control lists (ACLs) Off
  • Block public access to buckets and objects granted through new public bucket policies Off
  • Block public and cross-account access to buckets and objects through any public bucket policies Off

@albanallee Yes, I just check mine permission and looks the same as you suggest.

Directus uses https://github.com/thephpleague/flysystem So I think this might be something related to flysystem.

Can we close this issue?

Yep for sure. Thanks for your support @hemratna ;)

@hemratna — should we open a ticket over on flysystem so maybe this gets resolved?

@benhaynes I will run a test on local and raise a ticket with flysystem.

I am following all of @hemratna 's steps, until up to the switching off all the bucket permissions, and I'm still getting 'No permission to write: ...' error.

@1zaak Can you please try with a new bucket?

@hemratna Works now after I created a new bucket

Hi Folks,
the latest version has this bug.
I removed all permission to make this work, which is not ideal because we do have an access and secret key.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

metalmarco picture metalmarco  Â·  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  Â·  3Comments

chintohere picture chintohere  Â·  3Comments

rijkvanzanten picture rijkvanzanten  Â·  3Comments

binary-koan picture binary-koan  Â·  3Comments