-
-
Save bericp1/ff4596303a577ed19f5d330230a9e4fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const s3Client = ({ bucket }) => { | |
| // If the bucket is a "directory bucket" then we need to | |
| // use a custom endpoint via the availability zone. | |
| // See https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html | |
| if (bucket.endsWith('--x-s3')) { | |
| const bucketAndAzid = bucket.slice(0, -6); | |
| const parts = bucketAndAzid.split('--'); | |
| const azid = parts[parts.length - 1]; | |
| // See https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Regions-and-Zones.html | |
| const customEndpoint = `https://s3express-${azid}.${region}.amazonaws.com`; | |
| return new AWS.S3({ | |
| endpoint: customEndpoint, | |
| }); | |
| } | |
| return s3; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment