zoukankan      html  css  js  c++  java
  • 利用函数计算构建微信小程序的Server端

    10分钟上线 - 利用函数计算构建微信小程序的Server端-博客-云栖社区-阿里云 https://yq.aliyun.com/articles/435430

    函数计算  读写 oss

    import json
    import oss2
    import requests
    import time
    
    
    def my_handler(event=None, context=None):
        # evt = json.loads(event)
        # creds = context.credentials
        # 身份验证时,请不要遗漏了 security_token!
        # Do not miss the "security_token" for the authentication!
        # auth = oss2.StsAuth(creds.access_key_id, creds.access_key_secret, creds.security_token)
        kid, ks, ep, bn = '1', '2', 'oss-cn-beijing.aliyuncs.com', 'img'
        # bucket = oss2.Bucket(auth, evt['endpoint'], evt['bucket'])
        # bucket.put_object(evt['objectName'], evt['message'])
        auth = oss2.Auth(kid, ks)
        bucket = oss2.Bucket(auth, ep, bn)
    
        url = 'http://www.baidu.com/ReQ3M.mp4'
    
        d = requests.get(url)
        bytes_ = d._content
    
        f = '{}{}'.format('502', 'fw.mp4')
        # with open(f, 'wb') as fw:
        #     fw.write(bytes_)
    
        res = bucket.put_object(f, bytes_)
        print(res.resp.response.url)
    
        for obj in oss2.ObjectIterator(bucket):
            print(obj.key)
    
        return 'success'
  • 相关阅读:
    Daily Scrum 11.20
    Daily Scrum 11.19
    Daily Scrum 11.18
    Daily Scrum 11.17
    Daily Scrum 11.16
    Daily Scrum 11.15
    Loj10222佳佳的 Fibonacci
    CH3801Rainbow的信号
    js仓库。。。
    【UVa1635】Irrelevant Elements
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8980856.html
Copyright © 2011-2022 走看看