Esempio n. 1
0
    def upload_check(self, absolute_path, relatetive_path):
        # 图片上传
        self.file_id = relatetive_path
        image = tencentyun.ImageV2(self.app_id, self.secret_id,
                                   self.secret_key)
        obj = image.upload(absolute_path, self.bucket, self.file_id)
        print obj

        print image.delete(self.bucket, self.file_id)
        return obj
Esempio n. 2
0
    def push_binary_to_qclude(cls, binary, price=0):

        image = tencentyun.ImageV2(APPID, SECRET_ID, SECRET_KEY)

        if price == 0:
            pic_bucket = "hdlive"
        else:
            pic_bucket = "heydopic"

        return image.upload_binary(
            binary,
            bucket=pic_bucket,
            fileid=hashlib.md5("logo" + str(int(time.time()))).hexdigest())
Esempio n. 3
0
def picture_verify(picture):
    """第三方图片审核api(万象优图)"""
    appid = "10072767"  # 项目ID
    secret_id = "AKIDZBf2DdSCLNoAPXvH4kHeq2AHF1bz4b9a"  # 密钥ID
    secret_key = "1xjPxMjx4zsfGICvyvg4MX5cHAAze9Xp"  # 密钥key
    bucket = 'chuangyi'  # 图片空间名称
    image = tencentyun.ImageV2(appid, secret_id, secret_key)
    try:
        # image_data = open(picture_url, "rb").read()
        # 将图片上传到图片空间
        obj = image.upload_binary(picture, bucket)  # 第二个参数为空间名称
        if obj["code"] == 0:
            fileid = obj["data"]["fileid"]
            download_url = obj["data"]["download_url"]
            # 图片检测
            client = Client(appid, secret_id, secret_key, bucket)
            client.use_http()
            client.set_timeout(30)
            pornRet = client.porn_detect(CIUrls([download_url]))
            image.delete(bucket, fileid)
            return pornRet["result_list"][0]["data"]["result"]
    except IOError:
        return None
Esempio n. 4
0
#!/usr/bin/env python3

import time
import tencentyun

appid = "10000002"
secret_id = "AKIDL5iZVplWMenB5Zrx47X78mnCM3F5xDbC"
secret_key = "Lraz7n2vNcyW3tiP646xYdfr5KBV4YAv"

bucket = "test1"
fileid = "sample" + str(int(time.time()))

sample_image_path = "test_image.jpg"

image = tencentyun.ImageV2(appid, secret_id, secret_key)

# upload an image from local file
obj = image.upload(sample_image_path, bucket, fileid)
# or from in-memory binary data
# both upload and upload_binary is ok in Python 3
#image_data = open(sample_image_path, "rb").read()
#obj = image.upload(image_data, bucket, fileid)
#obj = image.upload_binary(image_data, bucket, fileid)
print("Update return info: ")
print(obj)

if obj["code"] == 0:
    fileid = obj["data"]["fileid"]
    statRet = image.stat(bucket, fileid)
    print("Status enquiry returns info: ")
    print(statRet)
Esempio n. 5
0
from flask.ext.moment import Moment  # 集成moment.js到Jinja2模板的Flask扩展。
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.pagedown import PageDown
bootstrap = Bootstrap()
mail = Mail()
moment = Moment()
pagedown = PageDown()
'''
#融云 您应该将key 和 secret 保存在服务器的环境变量中
os.environ.setdefault('rongcloud_app_key', conf.RONGCLOUD_APP_KEY)
os.environ.setdefault('rongcloud_app_secret', conf.RONGCLOUD_APP_SECRET)

db = MongoEngine()
mc = memcache.Client([conf.QCLOUD_MEMCACHED_IP],debug=0)
#rs= redis.StrictRedis(host='localhost', port=6379, db=0)
q_image = tencentyun.ImageV2(conf.QCLOUD_APPID,conf.QCLOUD_SECRET_ID,conf.QCLOUD_SECRET_KEY)
q_module = 'yunsou'
q_config = {
        'Region': 'gz',
        'secretId': conf.QCLOUDAPI_SECRET_ID,
        'secretKey': conf.QCLOUDAPI_SECRET_KEY,
        'method': 'get'
    }
q_search = QcloudApi(q_module, q_config)
rong_api = ApiClient()
#searchwhoosh = search.WhooshExpert()
login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'

Esempio n. 6
0
    def push_to_qclude(self):
        image = tencentyun.ImageV2(APPID, SECRET_ID, SECRET_KEY)

        return image.upload_binary(self.file_handler,
                                   bucket=BUCKET,
                                   fileid=self.file_id)