コード例 #1
0
 def post(self):
     domain = self.get_argument('domain', '')
     try:
         expires = int(self.get_argument('expires'))
         assert expires > 0
     except:
         expires = 3600
     key = self.get_argument('key', '')
     akey = self.get_argument('access_key', '')
     skey = self.get_argument('secret_key', '')
     if domain and key and akey and skey and expires:
         if len(key.split('?', 1)) > 1:
             key, fop = key.split('?', 1)
         else:
             key, fop = key, ''
         conf.ACCESS_KEY = str(akey)
         conf.SECRET_KEY = str(skey)
         url = rs.make_base_url(domain, key)
         if fop:
             url = '%s?%s' % (url, fop)
         policy = rs.GetPolicy()
         policy.expires = expires
         private_url = policy.make_request(url)
         self.set_cookie('downloadUrl', private_url)
     self.redirect('/make_download_url')
     return
コード例 #2
0
ファイル: storage.py プロジェクト: manlan2/qiniu-storage
 def url(self, name):
     name = self._clean_name(name)
     base_url = rs.make_base_url(self.bucket_host, name)
     if self.is_private:
         policy = rs.GetPolicy()
         return policy.make_request(base_url)
     else:
         return base_url
コード例 #3
0
	def test_get_policy(self):
		base_url = rs.make_base_url(domain, key)
		policy = rs.GetPolicy()
		private_url = policy.make_request(base_url)

		f = urllib.urlopen(private_url)
		body = f.read()
		f.close()
		self.assertEqual(len(body)>100, True)
コード例 #4
0
ファイル: diary.py プロジェクト: tiger8888/python
 def getData(self):
     url=rs.make_base_url(DOMAIN,self.filename)
     policy=rs.GetPolicy()
     private_url=policy.make_request(url)
     try:
         urllib.urlretrieve(private_url,Db)
     except:
         wx.CallAfter(self.showMsg,"数据库下载失败")
     wx.CallAfter(self.window.listDiaries)
     wx.CallAfter(self.showMsg,"数据库下载成功")