mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-07-12 23:00:55 +02:00
Support S3 region and enpoint options
This commit is contained in:
@ -152,6 +152,8 @@ type config struct {
|
|||||||
|
|
||||||
LocalFileSystemRoot string
|
LocalFileSystemRoot string
|
||||||
S3Enabled bool
|
S3Enabled bool
|
||||||
|
S3Region string
|
||||||
|
S3Endpoint string
|
||||||
GCSKey string
|
GCSKey string
|
||||||
|
|
||||||
ETagEnabled bool
|
ETagEnabled bool
|
||||||
@ -246,6 +248,9 @@ func init() {
|
|||||||
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")
|
||||||
|
|
||||||
boolEnvConfig(&conf.S3Enabled, "IMGPROXY_USE_S3")
|
boolEnvConfig(&conf.S3Enabled, "IMGPROXY_USE_S3")
|
||||||
|
strEnvConfig(&conf.S3Region, "IMGPROXY_S3_REGION")
|
||||||
|
strEnvConfig(&conf.S3Endpoint, "IMGPROXY_S3_ENDPOINT")
|
||||||
|
|
||||||
strEnvConfig(&conf.GCSKey, "IMGPROXY_GCS_KEY")
|
strEnvConfig(&conf.GCSKey, "IMGPROXY_GCS_KEY")
|
||||||
|
|
||||||
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
boolEnvConfig(&conf.ETagEnabled, "IMGPROXY_USE_ETAG")
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
imgproxy can process images from S3 buckets. To use this feature, do the following:
|
imgproxy can process images from S3 buckets. To use this feature, do the following:
|
||||||
|
|
||||||
1. Set `IMGPROXY_USE_S3` environment variable as `true`;
|
1. Set `IMGPROXY_USE_S3` environment variable as `true`;
|
||||||
2. [Setup credentials](#setup-credentials) to grant access to your bucket;
|
1. Specify AWS region with `IMGPROXY_S3_REGION` or `AWS_REGION`;
|
||||||
3. Use `s3://%bucket_name/%file_key` as the source image URL.
|
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
|
### Setup credentials
|
||||||
|
|
||||||
|
@ -15,7 +15,17 @@ type s3Transport struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newS3Transport() http.RoundTripper {
|
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) {
|
func (t s3Transport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
|
||||||
|
Reference in New Issue
Block a user