Exemplo n.º 1
0
func main() {
	log.SetFlags(0) // hide timestamps from Go logs

	parseFlags()

	resultBucketName = os.Getenv("RESULT_STORAGE_BUCKET")
	if resultBucketName != "" {
		keys, err := s3gof3r.EnvKeys()
		if err != nil {
			log.Fatal(err)
		}
		resultBucket = s3gof3r.New(s3gof3r.DefaultDomain, keys).Bucket(resultBucketName)
		resultBucket.Concurrency = 4
		resultBucket.PartSize = int64(2 * MB)
		resultBucket.Md5Check = false
		httpClient = resultBucket.Client

		if rrs := os.Getenv("USE_RRS"); rrs == "true" || rrs == "1" {
			useRRS = true
		}
	}

	router := httprouter.New()
	router.HEAD("/:signature/:size/*source", handleResize)
	router.GET("/:signature/:size/*source", handleResize)
	log.Fatal(http.ListenAndServe(listenInterface, router))
}
Exemplo n.º 2
0
// getAWSKeys gets the AWS Keys from environment variables or the instance-based metadata on EC2
// Environment variables are attempted first, followed by the instance-based credentials.
func getAWSKeys() (keys s3gof3r.Keys, err error) {

	keys, err = s3gof3r.EnvKeys()
	if err == nil {
		return
	}
	keys, err = s3gof3r.InstanceKeys()
	if err == nil {
		return
	}
	err = errors.New("no AWS keys found")
	return
}