Git Product home page Git Product logo

cos-python-sdk's People

Contributors

cliffordsun avatar konakonall avatar wangnan8791 avatar wucheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cos-python-sdk's Issues

secretKey 配置问题

pip install qcloud_cos 后,文件已经 copy 到了系统目录里面,没办法再去修改 conf.py 了。多个项目也无法使用不同的配置。能否改变一下配置的方式?比如用 class 实现?

cos上传api报错:TypeError: character mapping must return integer, None or unicode

sdk报错:
TypeError: character mapping must return integer, None or unicode

Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "./download_and_upload.py", line 140, in run
    self.upload(data, msg)
  File "./download_and_upload.py", line 118, in upload
    result = cos_api.statFile(bucket, cos_path)
  File "/usr/lib/python2.6/site-packages/qcloud_cos/cos.py", line 314, in statFile
    return self.__stat(bucket, path)
  File "/usr/lib/python2.6/site-packages/qcloud_cos/cos.py", line 327, in __stat
    sign = auth.sign_more(bucket, expired)
  File "/usr/lib/python2.6/site-packages/qcloud_cos/auth.py", line 62, in sign_more
    return self.app_sign(bucket, '', expired)
  File "/usr/lib/python2.6/site-packages/qcloud_cos/auth.py", line 51, in app_sign
    bin = hmac.new(self._secret_key, plain_text, hashlib.sha1)
  File "/usr/lib64/python2.6/hmac.py", line 133, in new
    return HMAC(key, msg, digestmod)
  File "/usr/lib64/python2.6/hmac.py", line 72, in __init__
    self.outer.update(key.translate(trans_5C))
TypeError: character mapping must return integer, None or unicode

`
主要原因:
python 2.6的hmac不支持unicode编码导致:
http://bugs.python.org/issue5285
解决方案:
传递给api的参数进行str处理:

cos_app_id = str(info['cos_app_id'])
cos_s_id = str(info['cos_s_id'])
cos_s_key = str(info['cos_s_key'])
bucket = str(info['cos_bucket'])
cos_api = qcloud_cos.Cos(cos_app_id, cos_s_id, cos_s_key)
result = cos_api.statFile(bucket, cos_path)

参考链接:
http://stackoverflow.com/questions/20849805/python-hmac-typeerror-character-mapping-must-return-integer-none-or-unicode/31572219

代码发生重大变化

发现代码发生重大变化,以前的cos下直接调用函数即可,现在改成request了,建议合并到qcloud-api-sdk中,这个sdk是可以恢复以前的接口?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.