Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0 (zero) bytes files in s3 after upload #158

Open
gansbrest opened this issue Mar 14, 2017 · 6 comments
Open

0 (zero) bytes files in s3 after upload #158

gansbrest opened this issue Mar 14, 2017 · 6 comments

Comments

@gansbrest
Copy link

Hi,

Installed and enabled your plugin on WP 4.7.2 multisite install, created new s3 bucket, IAM user.

Tried to upload a file using media library. It showed up in s3 - https://s3.amazonaws.com/mybucket.com/uploads/sites/3/2017/03/15289118_10153975276332327_12359350734570324_o.jpg

But the file is empty, zero bytes..

What could be the problem?

@gansbrest
Copy link
Author

This seem to be resolved by giving full permissions to s3, probably I missed some important bucket permissions. Is there a dock saying which permissions I need?

Also I noticed that when I delete image in WP, original image is not deleted, only 150x150 and 300x300 copies. Is that by design? ( why? )

@mattpramschufer
Copy link

mattpramschufer commented Mar 8, 2018

Just in case someone finds this and does NOT want to give full admin permissions, and does not use the wp-cli tool provided for creating IAM user. You can restrict user to specific bucket by using the following security policy

    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:PutObjectAclVersion",
                "s3:AbortMultipartUpload",
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::bucketname-here"
        },
        {
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:PutObjectAclVersion",
                "s3:AbortMultipartUpload",
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::bucketname-here/*"
        }
    ]
}

@ameiji
Copy link

ameiji commented Feb 10, 2020

I've also stumbled upon this issue. Changing default acl settings to "private" helped, and "s3:PutObjectAcl" permissions mentioned by @mattpramschufer were unnecessary.

define('S3_UPLOADS_OBJECT_ACL', 'private');

Hope it helps.

@aaronbrighton
Copy link

Just in case someone finds this and does NOT want to give full admin permissions, and does not use the wp-cli tool provided for creating IAM user. You can restrict user to specific bucket by using the following security policy

                "s3:PutObjectAcl",
                "s3:PutObjectAclVersion",

Thanks @mattpramschufer!

Ran into the same issue, adding these to the IAM role being used by S3-Uploads corrected the issue.

A bit of a gotcha, unfortunately the PHP error logs don't seem to throw any errors for this kind of issue.

I was using CDK, and incorrectly assumed mediaBucket.grantReadWrite(wordpressLambda) would be enough. Had to add to also add mediaBucket.grantPutAcl(wordpressLambda) to get the above PutObjectAcl* added to the IAM role.

@dmpinder
Copy link
Contributor

dmpinder commented Oct 9, 2021

I've also stumbled upon this issue. Changing default acl settings to "private" helped, and "s3:PutObjectAcl" permissions mentioned by @mattpramschufer were unnecessary.

define('S3_UPLOADS_OBJECT_ACL', 'private');

Hope it helps.

This helped me fix the issue, this was missing from my config.

@adambiggs
Copy link

Thanks @aaronbrighton, grantPutAcl() was the missing piece for us too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants