コード例 #1
0
config.SECRET_KEY = '<Dont send your secret key to anyone>'

bucket = 'test_photos'
key = 'test.jpg'
targetKey = 'cropped-' + key

tokenObj = uptoken.UploadToken(bucket, 3600)
uploadToken = tokenObj.generate_token()
print "Upload Token is: %s" % uploadToken

resp = rscli.UploadFile(bucket, key, 'image/jpg', key, '', '', uploadToken)
print '\n===> UploadFile %s result:' % key
print resp

client = digestoauth.Client()
rs = qboxrs.Service(client, bucket)

resp = rs.Get(key, key)
print '\n===> Get %s result:' % key
print resp

urlImageInfo = fileop.ImageInfoURL(resp['url'])
print "\n===> ImageInfo of %s:" % key
print urllib.urlopen(urlImageInfo).read()

urlImageSource = resp['url']
opts = {
    "thumbnail": "!120x120r",
    "gravity": "center",
    "crop": "!120x120a0a0",
    "quality": 85,
コード例 #2
0
import config
import urllib
import simpleoauth2
import rs as qboxrs
import rscli
import digestoauth
import uptoken

config.ACCESS_KEY = '3cmgyvf_rMTPuhlFNm1FS89q94Fykmb5ZWZAm92a'
config.SECRET_KEY = 'xFmoT2RvsnISK7NoqJuYElWSmkHON6eRLz2h9SL1'

bucket = 'bukaopu'
key = 'test.jpg'
customer = 'end_user_id'
demo_domain = 'test_photos.dn.qbox.me'

tokenObj = uptoken.UploadToken(bucket, 3600, "", "", customer)
uploadToken = tokenObj.generate_token()
print "Upload Token is: %s" % uploadToken

resp = rscli.UploadFile(bucket, key, 'image/jpg', key, '', '', uploadToken)
print '\n===> UploadFile %s result:' % key
print resp

client = digestoauth.Client()
rs = qboxrs.Service(client, bucket)

resp = rs.Stat(key)
print '\n===> Stat %s result:' % key
print resp
コード例 #3
0
ファイル: put_demo.py プロジェクト: tcmichael/python-sdk
#!/usr/bin/env python

import urllib
import simpleoauth2
import rs as qboxrs
import rscli

client = simpleoauth2.Client()
client.ExchangeByPassword('*****@*****.**', 'test')

tblName = 'tblName'
key = '2.jpg'

rs = qboxrs.Service(client, tblName)

resp = rs.PutAuth()
print '\n===> PutAuth %s result:' % key
print resp

resp = rscli.PutFile(str(resp['url']), tblName, key, '', key)
print '\n===> PutFile %s result:' % key
print resp

resp = rs.Stat(key)
print '\n===> Stat %s result:' % key
print resp