Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
Support Surrogate-Key
Browse files Browse the repository at this point in the history
This isn't ideal, but we can refactor later.
  • Loading branch information
fsouza committed Feb 6, 2018
1 parent def219f commit 919d4eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions s3-uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"mime"
"net"
"net/http"
"path"
"path/filepath"
"strings"
"time"
Expand All @@ -27,6 +28,7 @@ type Config struct {
HTTPPort int `envconfig:"HTTP_PORT" default:"80"`
LogLevel string `envconfig:"LOG_LEVEL" default:"debug"`
CacheControl cacheControlRules `envconfig:"CACHE_CONTROL_RULES"`
SurrogateKey bool `envconfig:"SURROGATE_KEY"`
}

func loadConfig() (Config, error) {
Expand Down Expand Up @@ -90,6 +92,12 @@ func main() {
ContentType: aws.String(contentType),
}
cfg.addCacheMetadata(&input)
if cfg.SurrogateKey {
p, _ := path.Split(key)
input.Metadata = map[string]string{
"Surrogate-Key": "video/" + strings.TrimRight(p, "/"),
}
}
_, err = uploader.Upload(&input)
if err != nil {
logger.WithFields(logFields).WithError(err).Error("failed to upload file")
Expand Down

0 comments on commit 919d4eb

Please sign in to comment.