mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-24 08:12:38 +02:00
Support S3 region and enpoint options
This commit is contained in:
parent
5985747aa6
commit
fc4a09f196
@ -152,6 +152,8 @@ type config struct {
|
||||
|
||||
LocalFileSystemRoot string
|
||||
S3Enabled bool
|
||||
S3Region string
|
||||
S3Endpoint string
|
||||
GCSKey string
|
||||
|
||||
ETagEnabled bool
|
||||
@ -246,6 +248,9 @@ func init() {
|
||||
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
||||
|
||||
boolEnvConfig(&conf.S3Enabled, "IMGPROXY_USE_S3")
|
||||
strEnvConfig(&conf.S3Region, "IMGPROXY_S3_REGION")
|
||||
strEnvConfig(&conf.S3Endpoint, "IMGPROXY_S3_ENDPOINT")
|
||||
|
||||
strEnvConfig(&conf.GCSKey, "IMGPROXY_GCS_KEY")
|
||||
|
||||
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
||||
|
@ -3,8 +3,10 @@
|
||||
imgproxy can process images from S3 buckets. To use this feature, do the following:
|
||||
|
||||
1. Set `IMGPROXY_USE_S3` environment variable as `true`;
|
||||
2. [Setup credentials](#setup-credentials) to grant access to your bucket;
|
||||
3. Use `s3://%bucket_name/%file_key` as the source image URL.
|
||||
1. Specify AWS region with `IMGPROXY_S3_REGION` or `AWS_REGION`;
|
||||
3. [Setup credentials](#setup-credentials) to grant access to your bucket;
|
||||
4. _(optional)_ Specify S3 endpoint with `IMGPROXY_S3_ENDPOINT`;
|
||||
5. Use `s3://%bucket_name/%file_key` as the source image URL.
|
||||
|
||||
### Setup credentials
|
||||
|
||||
|
@ -15,7 +15,17 @@ type s3Transport struct {
|
||||
}
|
||||
|
||||
func newS3Transport() http.RoundTripper {
|
||||
return s3Transport{s3.New(session.New())}
|
||||
s3Conf := aws.NewConfig()
|
||||
|
||||
if len(conf.S3Region) != 0 {
|
||||
s3Conf.WithRegion(conf.S3Region)
|
||||
}
|
||||
|
||||
if len(conf.S3Endpoint) != 0 {
|
||||
s3Conf.WithEndpoint(conf.S3Endpoint)
|
||||
}
|
||||
|
||||
return s3Transport{s3.New(session.New(), s3Conf)}
|
||||
}
|
||||
|
||||
func (t s3Transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user