humanmade / humanmade/S3-Uploads

"location constraint" error on some regions

Open
#406 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.2k
Forks
404
PR merge metrics
No merged PRs in 30d

Description

If you create a bucket in some regions then you get the below error when trying to access the file:

`
IllegalLocationConstraintException

The af-south-1 location constraint is incompatible for the region specific endpoint this request was sent to.

AA9313B3EA6564D2

GfLxHF3hvL+6o/ZCvkK1boSjj1Y+6m1/T1CqcsBAe4L9kB9m+eipqAiiin60ChdXXjwXR7TIp1Y=

`

Example for a bucket in "af-south-1" the S3 URL created is

https://{bucket}.s3.af-south-1.amazonaws.com/wordpressmedia/uploads/2020/05/test.jpg

but the plugin generates:

https://{bucket}.s3.amazonaws.com/wordpressmedia/uploads/2020/05/test-1024x191.jpg

on line 140 of class-s3-uploads.php the generated URL is:
`return apply_filters( 's3_uploads_bucket_url', 'https://' . $bucket . '.s3.amazonaws.com' . $path );`

perhaps it should be :

`
public function get_s3_url() {
if ( $this->bucket_url ) {
return $this->bucket_url;
}

$bucket = strtok( $this->bucket, '/' );
$path = substr( $this->bucket, strlen( $bucket ) );
$region = $this->region;

return apply_filters( 's3_uploads_bucket_url', 'https://' . $bucket . '.s3.'. $region .'.amazonaws.com' . $path );
}
`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in class-s3-uploads.php at line 140 and inspect get_s3_url(), especially how the bucket, path, and region are used. Reproduce the af-south-1 example and verify that generated URLs use the region-specific S3 endpoint while preserving the existing bucket path and filter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, php, wordpress
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.