humanmade / S3-Uploads

The WordPress Plugin to Store Uploads on Amazon S3
1.91k stars 389 forks source link

Uploading Media doesn't push to S3 #387

Closed jay-b closed 3 years ago

jay-b commented 4 years ago

I've got everything set up correctly as far as I can tell, when I run wp s3-uploads verify I get:

Success: Looks like your configuration is correct. I can push files fine with wp s3-uploads upload-directory

..but when I upload / drag an image in the Media Library, it uploads locally but doesn't push to S3. Checking the Attachment Details in the Media Library reveals the local link as well, not my CDN link.

Pretty stumped here, it just doesn't seem to work. No errors show either.

Any thoughts?

– Manually installed the plugin today, so it's the latest version. – WP v.5.3.2 testing locally on MAMP. – Tried: PHP 7.1.1, 7.3.9, 7.4.2 – Policy: { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt139000000000", "Effect": "Allow", "Action": [ "s3:AbortMultipartUpload", "s3:DeleteObject", "s3:GetBucketAcl", "s3:GetBucketLocation", "s3:GetBucketPolicy", "s3:GetObject", "s3:GetObjectAcl", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::assets.my-cdn.com/wp*" ] }, { "Sid": "AllowRootAndHomeListingOfBucket", "Action": [ "s3:ListBucket" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::assets.my-cdn.com" ], "Condition": { "StringLike": { "s3:prefix": [ "wp*" ] } } } ] }

Edits: Typos, Tried other PHP versions.

joehoyle commented 4 years ago

It sounds like the plugin isn't enabled in some way, as if you get your file appearing locally, it means S3 Uploads is not being used (S3 Uploads completely replaces the uploads directly). Most likely I thikn this would be due to another plugin conflicting. Can you try with only S3 Uploads enabnled?

ZY-Ang commented 4 years ago

I have the same problem (very recently). Tried on wordpress 5.3.2, 5.2.1 on php 7.3.9 and when I thought it could be a misconfiguration with the autogenerated IAM policy, I upgraded it to s3:* but it still doesn't do anything. Tested on both Amazon Linux and Ubuntu 18.04 running Apache 2.4. Also tested on AWS Lambda on Stackery's php 7.3 layer but instead of just uploading as a local file, the request completely times out on AWS Lambda, even though past implementations seem to have worked fine, assuming the plugin does write to /tmp before uploading. Also tested instance profile and manually adding keys.

I can't seem to find any logs on the issue anywhere.

Could it be that something changed on AWS' end?

RobertHosking commented 4 years ago

Same here. verify, and upload-directory commands work as expected but uploading media through the Media Library still uses the filesystem. Even though I've done wp s3-uploads enable the media urls are not being converted to s3 urls.

Also tried deactivating all plugins except s3-uploads.

Using S3-uploads Version 2.1.0-RC2 Wordpress 5.2.3 PHP 7.2.29

ZY-Ang commented 4 years ago

@joehoyle do you have a sample environment where the plugin still works?

rmccue commented 4 years ago

We're running S3 Uploads in production across all of our environments and they're still working; those are Ubuntu 16.04, PHP 7.2, and latest WordPress.

For us to be able to help here, we'd need more debugging information.

RobertHosking commented 4 years ago

@rmccue I've created a repo that runs a wordpress instance in docker with S3-uploads installed. The wordpress app is a Bedrock app. There's a guide for running locally the readme. https://github.com/RobertHosking/docker-wordpress-example

Once running, you should be able to recreate the issue by entering your s3 configs in wp-config.php and trying to upload some media.

Debug by docker exec -it <container_id> /bin/bash

jameslai commented 4 years ago

@jay-b Where in your wp-config.php did you add the configuration for the plugin? At the very end of the file? If it's included after the require for wp-settings, the constant's won't be registered by the time wp-uploads evaluates their presence and will exit out.

jameslai commented 4 years ago

@rmccue I've created a repo that runs a wordpress instance in docker with S3-uploads installed. The wordpress app is a Bedrock app. There's a guide for running locally the readme. https://github.com/RobertHosking/docker-wordpress-example

Once running, you should be able to recreate the issue by entering your s3 configs in wp-config.php and trying to upload some media.

Debug by docker exec -it <container_id> /bin/bash

Put the configuration settings before the require_once for wp-settings in your example repo.

isradelatorre commented 4 years ago

@rmccue I've created a repo that runs a wordpress instance in docker with S3-uploads installed. The wordpress app is a Bedrock app. There's a guide for running locally the readme. https://github.com/RobertHosking/docker-wordpress-example Once running, you should be able to recreate the issue by entering your s3 configs in wp-config.php and trying to upload some media. Debug by docker exec -it <container_id> /bin/bash

Put the configuration settings before the require_once for wp-settings in your example repo.

I had the same issue with a Bedrock WordPress site and this helped me solve it, thanks so much!!

shabin-slr commented 3 years ago

@jay-b Where in your wp-config.php did you add the configuration for the plugin? At the very end of the file? If it's included after the require for wp-settings, the constant's won't be registered by the time wp-uploads evaluates their presence and will exit out.

If this is not considered a bug, can this instruction be included in the Readme.md ?

rmccue commented 3 years ago

@shabin-slr This is standard WordPress configuration behaviour, not specific to S3 Uploads, so there are no plans to add it to our documentation.

jameslai commented 3 years ago

This issue should be marked as resolved.

shabin-slr commented 3 years ago

@rmccue, not everyone may be aware of this, like OP and I. Kindly add this as an instruction in docs.

rmccue commented 3 years ago

@shabin-slr Per our support policy, we do not provide support for basic usage of WordPress, and this is assumed knowledge for using this plugin. If you're looking for a more consumer-friendly plugin, we recommend using WP Offload Media instead. :)