Bmob使用python上传文件

2019-03-04  本文已影响0人  Leo_23

使用python的requests结合rest-api上传文件到bmob服务器


import requests


def main():
    url = "https://api2.bmob.cn/2/files/%s" % "HSSN-100L01L-M_1.jpg"
    headers = {
        "X-Bmob-Application-Id": "xxx",
        "X-Bmob-REST-API-Key": "xxx",
        "Content-Type": "image/jpeg",
    }
    data = open('./HSSN-100L01L-M_1.jpg', 'rb').read()
    res = requests.post(url, headers=headers, data=data)
    print(res)
    print(list(res))

if __name__ == '__main__':
    main()

上一篇下一篇

猜你喜欢

热点阅读