Exemple #1
0
func (self *proxyConf) UnmarshalJSON(in []byte) (err os.Error) {
	confmap := map[string]string{}
	err = json.Unmarshal(in, &confmap)
	if err == nil {
		if _, ok := confmap["Bucket"]; !ok {
			return os.NewError("Bucket is required")
		}
		self.Prefix = confmap["Prefix"]
		if self.Prefix == "" {
			self.Prefix = "/"
		}
		self.Bucket = s3.NewBucket(&http.URL{
			Scheme: "http",
			Host:   "s3.amazonaws.com",
			Path:   self.Prefix,
		}, confmap["Bucket"], nil)

		if confmap["AccessKey"] != "" && confmap["SecretKey"] != "" {
			self.Identity = aws.NewSigner(confmap["AccessKey"], confmap["SecretKey"])
		} else {
			self.Identity, err = DefaultSigner()
		}
	}
	return
}
Exemple #2
0
// Returns the aws.Signer associated with the aws-*-key flags.
func DefaultSigner() (signer *aws.Signer, err os.Error) {
	if accessKey == nil || secretKey == nil {
		flag.Parse()
	}
	if *accessKey == "" || *secretKey == "" {
		err = os.NewError("No default access key provided")
	} else {
		signer = aws.NewSigner(*accessKey, *secretKey)
	}
	return
}