adding azure support

This commit is contained in:
Paul Roy 2016-12-28 18:36:30 +01:00 committed by Will Norris
parent 03d75816a0
commit f1ef8af9ec
2 changed files with 10 additions and 4 deletions

View file

@ -101,10 +101,13 @@ enabled using the `-cache` flag. It supports the following values:
- s3 URL (e.g. `s3://s3-us-west-2.amazonaws.com/my-bucket`) - will cache - s3 URL (e.g. `s3://s3-us-west-2.amazonaws.com/my-bucket`) - will cache
images on Amazon S3. This requires either an IAM role and instance profile images on Amazon S3. This requires either an IAM role and instance profile
with access to your your bucket or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY` with access to your your bucket or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`
environmental parameters set. environmental variables be set.
- GCS URL (e.g. `gcs://bucket-name/optional-path-prefix`) - will cache - gcs URL (e.g. `gcs://bucket-name/optional-path-prefix`) - will cache images
images on Google Cloud Storage. This requires `GCP_PRIVATE_KEY` environmental on Google Cloud Storage. This requires `GCP_PRIVATE_KEY` environmental
parameters set. variable be set.
- azure URL (e.g. `azure://container-name/`) - will cache images on
Azure Storage. This requires `AZURESTORAGE_ACCOUNT_NAME` and
`AZURESTORAGE_ACCESS_KEY` environmental variables set.
For example, to cache files on disk in the `/tmp/imageproxy` directory: For example, to cache files on disk in the `/tmp/imageproxy` directory:

View file

@ -24,6 +24,7 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/PaulARoy/azurestoragecache"
"github.com/diegomarangoni/gcscache" "github.com/diegomarangoni/gcscache"
"github.com/gregjones/httpcache" "github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache" "github.com/gregjones/httpcache/diskcache"
@ -129,6 +130,8 @@ func parseCache() (imageproxy.Cache, error) {
return s3cache.New(u.String()), nil return s3cache.New(u.String()), nil
case "gcs": case "gcs":
return gcscache.New(u.String()), nil return gcscache.New(u.String()), nil
case "azure":
return azurestoragecache.New("", "", u.Host)
case "file": case "file":
fallthrough fallthrough
default: default: