Exemple #1
0
def __refresh_sign_parameters(parameters,
                              access_key_id,
                              accept_format="JSON",
                              signer=mac1):
    if parameters is None or not isinstance(parameters, dict):
        parameters = dict()
    parameters["Timestamp"] = helper.get_iso_8061_date()
    parameters["SignatureMethod"] = signer.get_signer_name()
    parameters["SignatureType"] = signer.get_signer_type()
    parameters["SignatureVersion"] = signer.get_singer_version()
    parameters["SignatureNonce"] = helper.get_uuid()
    parameters["AccessKeyId"] = access_key_id
    if accept_format is not None:
        parameters["Format"] = accept_format
    return parameters
Exemple #2
0
 def test_get_uuid(self):
     uuid = helper.get_uuid()
     self.assertEqual(36, len(uuid))
     self.assertNotEqual(helper.get_uuid(), helper.get_uuid())
    def __reportUploadProgress(self, uploadMethod, donePartsCount, doneBytes):
        reportHost = 'vod.cn-shanghai.aliyuncs.com'
        sdkVersion = '1.3.1'
        reportKey = 'HBL9nnSwhtU2$STX'

        uploadPoint = {
            'upMethod': uploadMethod,
            'partSize': self.__partSize,
            'doneBytes': doneBytes
        }
        timestamp = int(time.time())
        authInfo = AliyunVodUtils.getStringMd5(
            "%s|%s|%s" % (self.__clientId, reportKey, timestamp))

        fields = {
            'Action':
            'ReportUploadProgress',
            'Format':
            'JSON',
            'Version':
            '2017-03-21',
            'Timestamp':
            helper.get_iso_8061_date(),
            'SignatureNonce':
            helper.get_uuid(),
            'VideoId':
            self.__uploadInfo['MediaId'],
            'Source':
            'PythonSDK',
            'ClientId':
            self.__clientId,
            'BusinessType':
            'UploadVideo',
            'TerminalType':
            'PC',
            'DeviceModel':
            'Server',
            'AppVersion':
            sdkVersion,
            'AuthTimestamp':
            timestamp,
            'AuthInfo':
            authInfo,
            'FileName':
            self.__filePath,
            'FileHash':
            self.__getFilePartHash(self.__clientId, self.__filePath,
                                   self.__totalSize),
            'FileSize':
            self.__totalSize,
            'FileCreateTime':
            timestamp,
            'UploadRatio':
            0,
            'UploadId':
            self.__uploadId,
            'DonePartsCount':
            donePartsCount,
            'PartSize':
            self.__partSize,
            'UploadPoint':
            json.dumps(uploadPoint),
            'UploadAddress':
            self.__uploadInfo['OriUploadAddress']
        }
        requests.post('http://' + reportHost, fields, timeout=1)
Exemple #4
0
#
url = 'http://vod.cn-shanghai.aliyuncs.com/?'
accessKeyId = accessKeyId  ##修改您的信息
accessKeySecret = accessKeySecret  ##修改您的信息
parameters = {
    'Title': 'xxx',
    'FileName': 'xxx.m4a',
    'FileSize': '3442197',
    'Description': 'Description',
    'Format': 'JSON',
    'Version': '2017-03-21',
    'AccessKeyId': accessKeyId,
    'SignatureMethod': 'HMAC-SHA1',
    'Timestamp': helper.get_iso_8061_date(),
    'SignatureVersion': '1.0',
    'SignatureNonce': helper.get_uuid()
}


def urlencode(query):
    ret = urllib.urlencode(query)
    ret = ret.replace('+', '%20')
    ret = ret.replace('*', '%2A')
    ret = ret.replace('%7E', '~')
    return ret


def getSignature(parameters, action):
    dic = {'Action': action}
    parameters = dict(parameters, **dic)
    sorted_parameters = sorted(parameters.items(),