Esempio n. 1
0
 def canonical_resource(self):
     res = "/"
     if self.bucket:
         res += aws_urlquote(self.bucket)
     if self.key is not None:
         res += "/%s" % aws_urlquote(self.key)
     if self.subresource:
         res += "?%s" % aws_urlquote(self.subresource)
     return res
Esempio n. 2
0
 def canonical_resource(self):
     res = "/"
     if self.bucket:
         res += aws_urlquote(self.bucket)
     if self.key is not None:
         res += "/%s" % aws_urlquote(self.key)
     if self.subresource:
         res += "?%s" % aws_urlquote(self.subresource)
     return res
Esempio n. 3
0
 def __init__(self, name=None, access_key=None, secret_key=None,
              base_url=None, timeout=None, secure=False):
     scheme = ("http", "https")[int(bool(secure))]
     if not base_url:
         base_url = "%s://%s" % (scheme, amazon_s3_domain)
         if name:
             base_url += "/%s" % aws_urlquote(name)
     elif secure is not None:
         if not base_url.startswith(scheme + "://"):
             raise ValueError("secure=%r, url must use %s"
                              % (secure, scheme))
     self.opener = self.build_opener()
     self.name = name
     self.access_key = access_key
     self.secret_key = secret_key
     self.base_url = base_url
     self.timeout = timeout
Esempio n. 4
0
 def url(self, base_url, arg_sep="&"):
     url = base_url + "/"
     if self.key:
         url += aws_urlquote(self.key)
     if self.subresource or self.args:
         ps = []
         if self.subresource:
             ps.append(self.subresource)
         if self.args:
             args = self.args
             if hasattr(args, "iteritems"):
                 args = args.iteritems()
             args = ((quote_plus(k), quote_plus(v)) for (k, v) in args)
             args = arg_sep.join("%s=%s" % i for i in args)
             ps.append(args)
         url += "?" + "&".join(ps)
     # print url
     return url
Esempio n. 5
0
 def url(self, base_url, arg_sep="&"):
     url = base_url + "/"
     if self.key:
         url += aws_urlquote(self.key)
     if self.subresource or self.args:
         ps = []
         if self.subresource:
             ps.append(self.subresource)
         if self.args:
             args = self.args
             if hasattr(args, "iteritems"):
                 args = args.iteritems()
             args = ((quote_plus(k), quote_plus(v)) for (k, v) in args)
             args = arg_sep.join("%s=%s" % i for i in args)
             ps.append(args)
         url += "?" + "&".join(ps)
     # print url
     return url
Esempio n. 6
0
 def __init__(self,
              name=None,
              access_key=None,
              secret_key=None,
              base_url=None,
              timeout=None,
              secure=False):
     scheme = ("http", "https")[int(bool(secure))]
     if not base_url:
         base_url = "%s://%s" % (scheme, amazon_s3_domain)
         if name:
             base_url += "/%s" % aws_urlquote(name)
     elif secure is not None:
         if not base_url.startswith(scheme + "://"):
             raise ValueError("secure=%r, url must use %s" %
                              (secure, scheme))
     self.opener = self.build_opener()
     self.name = name
     self.access_key = access_key
     self.secret_key = secret_key
     self.base_url = base_url
     self.timeout = timeout