humanmade / S3-Uploads

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

S3 Upload on Windows server #652

Open workcodework opened 1 year ago

workcodework commented 1 year ago

Hey,

I need your help. I can't seem to get S3 Uploads to work with Wordpress, on a windows server. With S3 Upload enabled, I'm unable to upload anything via media library to AWS.

The server cannot process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.

This only happens when the S3 Upload plugin is enabled. We've migrated the same website (which had no issue with S3 Upload) from a non-windows server, with all major settings in tact or applied.

What could be issue here?

rmccue commented 1 year ago

You'll need to check your PHP error log to find out exactly what the error here, as I believe this message is a generic error message when something fails to upload.

Please note that we can't provide extensive support for debugging, so you'll need to dig into this yourself first: https://engineering.hmn.md/projects/support/

workcodework commented 1 year ago

Understood and I appreciate the help.

There doesn't seem to be a lot of resources on my predicament. This is the error log (after trying to upload image in WP Media Library):

[14-Sep-2023 16:52:26 UTC] PHP Warning: scandir(): S3_Uploads\Stream_Wrapper::dir_readdir is not implemented! in D:[REDACTED]\wp-content\plugins\S3-Uploads-1\inc\class-plugin.php on line 676 [14-Sep-2023 16:52:26 UTC] PHP Fatal error: Uncaught exception 'Aws\S3\Exception\S3Exception' with message 'Error executing "ListObjectsV2" on "https://[REDACTED].s3.ap-southeast-1.amazonaws.com/?list-type=2&delimiter=%2F&prefix=uploads%2F2023%2F09%2Fnewsletter-field-desktop"; AWS HTTP error: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://[REDACTED].s3.ap-southeast-1.amazonaws.com/?list-type=2&delimiter=%2F&prefix=uploads%2F2023%2F09%2Fnewsletter-field-desktop'

Seems like SSL/cURL AWS connection issue?

Edit: Got it. not asking for extensive support. Thanks anyway

tomjn commented 11 months ago

dir_readdir is implemented: https://github.com/humanmade/S3-Uploads/blob/master/inc/class-stream-wrapper.php#L693

error: cURL error 60: SSL certificate problem: unable to get local issuer certificate

It's more likely to be the AWS SSL issue, perhaps you've got a custom certificate setup via a custom root certificate authority? If that's the case I'm not sure what to advise

workcodework commented 11 months ago

Thanks for the input @tomjn.

We resolved the issue on our win IIS server as follow (roughly): 1) Installed the php extension cURL and SSL

2) Followed by latest version of cacert.pem (certificate configuration), https://curl.se/docs/caextract.html Learn more here: https://stackoverflow.com/questions/38667165/amazon-s3-upload-error-ssl-certificate-issues/38667282#38667282

3) Upload is working, but 0 bytes files were getting uploaded. Solved it by added this line to wp-config.php: define( 'S3_UPLOADS_OBJECT_ACL', ‘private’); Learn more here: https://github.com/humanmade/S3-Uploads/issues/158

4) Ran into the deletion issue (file deleted from WP didn't delete from S3) Adding to policy "s3:*" to Action worked Learn more here: https://github.com/humanmade/S3-Uploads/issues/196

There was a lot of testing, so I may have missed a step or two.