开发者社区> 问答> 正文

linux下python SDK的分片上传有403 BUG,麻烦修复下

环境ubuntu 64位, python3.4.3
普通断点上传正常,分片上传403错误

测试代码
auth = oss2.Auth('我的id', '我的key')
        bucket = oss2.Bucket(auth,'oss-cn-beijing.aliyuncs.com', 'dtap')
        try:
#简单断点上传,上传成功

            oss2.resumable_upload(bucket, '16050415580881917', '/root/桌面/16050415580881917.gif')   #没有问题上传成功
#分片上传1,403错误

            oss2.resumable_upload(bucket, '16050415580881917', '/root/桌面/16050415580881917.gif', multipart_threshold=100 * 1024) #上传失败
#分片上传2,403错误

            total_size = os.path.getsize('/root/桌面/16050415580881917.gif')
            part_size = oss2.determine_part_size(total_size, preferred_size=128 * 1024)
            upload_id = bucket.init_multipart_upload('16050415580881917').upload_id
            with open('/root/桌面/16050415580881917.gif', 'rb') as fileobj:
                parts = []
                part_number = 1
                offset = 0
                while offset < total_size:
                    num_to_upload = min(part_size, total_size - offset)
                    result = bucket.upload_part('16050415580881917', upload_id, part_number,
                                                oss2.SizedFileAdapter(fileobj, num_to_upload))
                    parts.append(oss2.models.PartInfo(part_number, result.etag))
                    offset += num_to_upload
                    part_number += 1
                bucket.complete_multipart_upload('16050415580881917', upload_id, parts)
        except Exception as e:
            print(e)
            time.sleep(10)

错误消息统一为
{'details': {'Code': 'SignatureDoesNotMatch', 'StringToSign': 'POST\n\napplication/x-www-form-urlencoded\nFri, 23 Dec 2016 09:41:50 GMT\n/dtap/16050415580881916?uploadId=0116367504714646848EC982E26AC317', 'OSSAccessKeyId': 'LTAI6L8wYzFhiR3R', 'StringToSignBytes': '50 4F 53 54 0A 0A 61 70 70 6C 69 63 61 74 69 6F 6E 2F 78 2D 77 77 77 2D 66 6F 72 6D 2D 75 72 6C 65 6E 63 6F 64 65 64 0A 46 72 69 2C 20 32 33 20 44 65 63 20 32 30 31 36 20 30 39 3A 34 31 3A 35 30 20 47 4D 54 0A 2F 64 74 61 70 2F 31 36 30 35 30 34 31 35 35 38 30 38 38 31 39 31 36 3F 75 70 6C 6F 61 64 49 64 3D 30 31 31 36 33 36 37 35 30 34 37 31 34 36 34 36 38 34 38 45 43 39 38 32 45 32 36 41 43 33 31 37 ', 'Message': 'The request signature we calculated does not match the signature you provided. Check your key and signing method.', 'SignatureProvided': 'j3r6XyQ2e2BVOHzbtGAxKhWzw5Q=', 'RequestId': '585CF15D1B658DF847091A69', 'HostId': 'dtap.oss-cn-beijing.aliyuncs.com'}, 'status': 403}

另外有一点值得注意,似乎是在上传过程中出现异常,我在分片上传2循环中打断点,手动控制它不执行那么快,有时候是可以上传成功的,这似乎是个BUG?麻烦看下,不用分片上传的话速度太慢

展开
收起
千里东风 2016-12-23 17:47:24 3016 0
2 条回答
写回答
取消 提交回答
  • 阿里云用户
    @scorpion
    @oss-dev
    我试试看能呼叫不
    2016-12-27 19:49:28
    赞同 展开评论 打赏
  • 回 楼主千里东风的帖子
    另外再补充一点,同样的代码在WIN7下完全正常,代码不变,在Ubuntu下就出这个问题

    -------------------------

    Relinux下python SDK的分片上传有403 BUG,麻烦修复下
    Ubuntu是 14.04 64位
    2016-12-23 17:57:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载