mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Add IMGPROXY_GCS_ENDPOINT config
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
- Add `IMGPROXY_FALLBACK_IMAGE_TTL` config.
|
- Add `IMGPROXY_FALLBACK_IMAGE_TTL` config.
|
||||||
- (pro) Add [watermark_size](https://docs.imgproxy.net/generating_the_url?id=watermark-size) processing option.
|
- (pro) Add [watermark_size](https://docs.imgproxy.net/generating_the_url?id=watermark-size) processing option.
|
||||||
- Add OpenStack Object Storage ("Swift") support.
|
- Add OpenStack Object Storage ("Swift") support.
|
||||||
|
- Add `IMGPROXY_GCS_ENDPOINT` config.
|
||||||
|
|
||||||
### Change
|
### Change
|
||||||
- (pro) Don't check `Content-Length` header of videos.
|
- (pro) Don't check `Content-Length` header of videos.
|
||||||
|
@@ -87,6 +87,7 @@ var (
|
|||||||
|
|
||||||
GCSEnabled bool
|
GCSEnabled bool
|
||||||
GCSKey string
|
GCSKey string
|
||||||
|
GCSEndpoint string
|
||||||
|
|
||||||
ABSEnabled bool
|
ABSEnabled bool
|
||||||
ABSName string
|
ABSName string
|
||||||
@@ -400,6 +401,7 @@ func Configure() error {
|
|||||||
|
|
||||||
configurators.Bool(&GCSEnabled, "IMGPROXY_USE_GCS")
|
configurators.Bool(&GCSEnabled, "IMGPROXY_USE_GCS")
|
||||||
configurators.String(&GCSKey, "IMGPROXY_GCS_KEY")
|
configurators.String(&GCSKey, "IMGPROXY_GCS_KEY")
|
||||||
|
configurators.String(&GCSEndpoint, "IMGPROXY_GCS_ENDPOINT")
|
||||||
|
|
||||||
configurators.Bool(&ABSEnabled, "IMGPROXY_USE_ABS")
|
configurators.Bool(&ABSEnabled, "IMGPROXY_USE_ABS")
|
||||||
configurators.String(&ABSName, "IMGPROXY_ABS_NAME")
|
configurators.String(&ABSName, "IMGPROXY_ABS_NAME")
|
||||||
|
@@ -308,9 +308,11 @@ Check out the [Serving files from S3](serving_files_from_s3.md) guide to learn m
|
|||||||
|
|
||||||
## Serving files from Google Cloud Storage
|
## Serving files from Google Cloud Storage
|
||||||
|
|
||||||
imgproxy can process files from Google Cloud Storage buckets, but this feature is disabled by default. To enable it, set the value of `IMGPROXY_GCS_KEY` to the content of the Google Cloud JSON key:
|
imgproxy can process files from Google Cloud Storage buckets, but this feature is disabled by default. To enable it, set the value of `IMGPROXY_USE_GCS` to `true`:
|
||||||
|
|
||||||
|
* `IMGPROXY_USE_GCS`: when `true`, enables image fetching from Google Cloud Storage buckets. Default: `false`
|
||||||
* `IMGPROXY_GCS_KEY`: the Google Cloud JSON key. When set, enables image fetching from Google Cloud Storage buckets. Default: blank
|
* `IMGPROXY_GCS_KEY`: the Google Cloud JSON key. When set, enables image fetching from Google Cloud Storage buckets. Default: blank
|
||||||
|
* `IMGPROXY_GCS_ENDPOINT`: a custom Google Cloud Storage endpoint to being used by imgproxy
|
||||||
|
|
||||||
Check out the [Serving files from Google Cloud Storage](serving_files_from_google_cloud_storage.md) guide to learn more.
|
Check out the [Serving files from Google Cloud Storage](serving_files_from_google_cloud_storage.md) guide to learn more.
|
||||||
|
|
||||||
|
@@ -4,7 +4,8 @@ imgproxy can process images from Google Cloud Storage buckets. To use this featu
|
|||||||
|
|
||||||
1. Set the `IMGPROXY_USE_GCS` environment variable to `true`.
|
1. Set the `IMGPROXY_USE_GCS` environment variable to `true`.
|
||||||
2. [Set up credentials](#setup-credentials) to grant access to your bucket.
|
2. [Set up credentials](#setup-credentials) to grant access to your bucket.
|
||||||
3. Use `gs://%bucket_name/%file_key` as the source image URL.
|
3. _(optional)_ Specify the Google Cloud Storage endpoint with `IMGPROXY_GCS_ENDPOINT`.
|
||||||
|
4. Use `gs://%bucket_name/%file_key` as the source image URL.
|
||||||
|
|
||||||
If you need to specify generation of the source object, you can use the query string of the source URL:
|
If you need to specify generation of the source object, you can use the query string of the source URL:
|
||||||
|
|
||||||
|
@@ -13,6 +13,9 @@ import (
|
|||||||
"github.com/imgproxy/imgproxy/v3/config"
|
"github.com/imgproxy/imgproxy/v3/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// For tests
|
||||||
|
var noAuth bool = false
|
||||||
|
|
||||||
type transport struct {
|
type transport struct {
|
||||||
client *storage.Client
|
client *storage.Client
|
||||||
}
|
}
|
||||||
@@ -23,12 +26,22 @@ func New() (http.RoundTripper, error) {
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opts := []option.ClientOption{}
|
||||||
|
|
||||||
if len(config.GCSKey) > 0 {
|
if len(config.GCSKey) > 0 {
|
||||||
client, err = storage.NewClient(context.Background(), option.WithCredentialsJSON([]byte(config.GCSKey)))
|
opts = append(opts, option.WithCredentialsJSON([]byte(config.GCSKey)))
|
||||||
} else {
|
|
||||||
client, err = storage.NewClient(context.Background())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(config.GCSEndpoint) > 0 {
|
||||||
|
opts = append(opts, option.WithEndpoint(config.GCSEndpoint))
|
||||||
|
}
|
||||||
|
|
||||||
|
if noAuth {
|
||||||
|
opts = append(opts, option.WithoutAuthentication())
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err = storage.NewClient(context.Background(), opts...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Can't create GCS client: %s", err)
|
return nil, fmt.Errorf("Can't create GCS client: %s", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user