I want sent a post request

i have to use English ,becasue my RaspberryPi don't have pinyin

please use Cinese answer the question .

exception:

[TencentCloudSDKException] code:AuthFailure.SignatureFailure message:The provided credentials could not be validated because of exceeding request size limit, please use new signature method `TC3-HMAC-SHA256`. requestId:92c2a31c-4afe-4f34-a9e2-dc4fe2b35fc8

my code:

# helloworld/helloworld/view.py
from PIL import Image
import uuid
from django.http import HttpResponse
import json
from picamera import PiCamera
from time import sleep
import random
import requests
import datetime
import os
import base64
import sys
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException 
from tencentcloud.iai.v20180301 import iai_client, models 

def get_size(file):
    # 获取文件大小:KB
    size = os.path.getsize(file)
    return size / 1024

def get_outfile(infile, outfile):
    if outfile:
        return outfile
    dir, suffix = os.path.splitext(infile)
    outfile = '{}-out{}'.format(dir, suffix)
    return outfile

def compress_image(infile, outfile='', mb=9000, step=10, quality=80):
    """不改变图片尺寸压缩到指定大小
    :param infile: 压缩源文件
    :param outfile: 压缩文件保存地址
    :param mb: 压缩目标,KB
    :param step: 每次调整的压缩比率
    :param quality: 初始压缩比率
    :return: 压缩文件地址,压缩文件大小
    """
    o_size = get_size(infile)
    if o_size <= mb:
        return infile
    outfile = get_outfile(infile, outfile)
    while o_size > mb:
        im = Image.open(infile)
        im.save(outfile, quality=quality)
        if quality - step < 0:
            break
        quality -= step
        o_size = get_size(outfile)
    return outfile, get_size(outfile)

def createAnImage():
    camera = PiCamera()
    # camera.start_preview()
    camera.rotation = 180
    sleep(2)

    fileNameArry = []
    for i in range(0, 5):
        fileNameArry.append(random.randint(1, 50))
    fileName = "".join(str(word) for word in fileNameArry)
    longFileName = "/home/pi/Desktop/images/" + fileName + ".jpg"
    camera.capture(longFileName)
    compress_image(longFileName)
    # camera.stop_preview()
    return longFileName

def imageToBase64(langFileName):
    
    with open(langFileName, 'rb') as f:
        base64_data = base64.b64encode(f.read())
        s = base64_data.decode()
        return s

def creatPerson(FileName,personName,personId):

    try:
        cred = credential.Credential("AKIDthNtIXWTczdCdxrJM9qLivxnRQRGFLbi", "5zIWZP3WouoPuENKLCrL5g6OVTGswuWL") 
        httpProfile = HttpProfile()
        httpProfile.endpoint = "iai.tencentcloudapi.com"

        clientProfile = ClientProfile()
        clientProfile.httpProfile = httpProfile
        client = iai_client.IaiClient(cred, "ap-beijing", clientProfile)

        req = models.CreatePersonRequest()
        params = '{"GroupId":"group1","PersonName":"'+ personName +'","PersonId":"'+ personId +'","Image":"'+ imageToBase64(FileName) +'"}'
        req.from_json_string(params)

        resp = client.CreatePerson(req) 
        print(resp.to_json_string()) 

    except TencentCloudSDKException as err: 
        print(err) 


def addFamily(request):
    global return_json

    if request.is_ajax():

        data = json.loads(request.body.decode("utf8"))
        
        print(data)
        
        tencentReturnFlag = creatPerson()

        if BaiduReturnFlag == "0":
            return_json = {"msg": "添加成功"}
        else:
            return_json = {"msg": "添加失败"}
        
        os.remove(longFileName)

        return HttpResponse(json.dumps(return_json))
    
creatPerson(createAnImage(),"didi","201703204322")

FFFF0H.FFFF0H.提问于
流星留步Android, H5, ReactNative, 小程序回答于

你这是签名过期,看起来是签名方法有问题。

回答过的其他问题

AI领域无监督学习有哪些难点?

流星留步Android, H5, ReactNative, 小程序
AI领域目前主流的学习方式是无监督学习,无监督学习主要是通过大量已经人为标注好的数据进行训练。这需要耗费大量的人力物力。而且很难在实际运行中边工作边学习。比如说图像分类,我们利用大量标注好的数据对模型进行训练,训练好以后将模型应用到实际应用的场合。但是模型的参数在实际应用中将不再...... 展开详请

相对于传统的数据库开发,TXSQL对开发者能更为友好吗?语法一致吗?

流星留步Android, H5, ReactNative, 小程序
TXSQL是腾讯基础架构部数据库团队自研的MySQL分支,对腾讯云以及众多的内部业务提供了强大的数据库内核支撑。相比原生的MySQL,TXSQL在BINLOG复制和InnoDB存储引擎方面做了很多的优化,另外在Server层面也做了大量的工作。因此TXSQL拥有更好的性能,更好的...... 展开详请

腾讯云是如何解决小程序开发的难题?

流星留步Android, H5, ReactNative, 小程序

腾讯云微信小程序特性打造的一站式解决方案,是小程序的服务器推荐服务商,也是原生案例的提供者。

腾讯智能云为开发者带来哪些便利?

流星留步Android, H5, ReactNative, 小程序

不用造轮子了。去开源项目找。

接口做好了,自己对接就行了。

将云平台与AI结合起来有什么优势?

流星留步Android, H5, ReactNative, 小程序

游戏外挂有哪些危害?如何提前揭露?

流星留步Android, H5, ReactNative, 小程序

对游戏软件的修改必将破坏游戏数据,而修改、破坏数据可能造成游戏运行出错,严重的可以造成游戏服务器重要资源损坏、丢失。 破坏游戏平衡性,缩短游戏寿命,导致已有用户的流失。

扫码关注云+社区

领取腾讯云代金券