Coder Social home page Coder Social logo

python-sdk's People

Contributors

chzhuo avatar forthe2008 avatar fzhyzamt avatar huangnauh avatar i1mt avatar januszry avatar mengskysama avatar mohanson avatar monhz avatar tgmerge avatar timebug avatar yejingx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

python-sdk's Issues

分块上传种 kwargs 参数文档描述错误

readme 文档中, 分块上传部分的参数

with open('unix.png', 'rb') as f:
    res = up.put('/upyun-python-sdk/xinu.png', f, checksum=True, multipart=True, block_size=1024*1024, kwargs=kwargs)

有误

应该是

with open('unix.png', 'rb') as f:
    res = up.put('/upyun-python-sdk/xinu.png', f, checksum=True, multipart=True, block_size=1024*1024, **kwargs)

目前版本的python sdk不支持上传文件和下载文件的进度条显示功能

如果项目利用python sdk来上传、下载文件,大多应该是在terminal运行的吧? 如果没有progress bar,上传个稍微大点的文件就体验就特别不好了~~
我在我的项目写了一个往upyun上传文件,支持终端实时显示上传进度、上传速度等等信息的code。 你如果感兴趣,可以考虑加上类似的功能o(∩_∩)o
https://github.com/wh1100717/PolySpider/blob/master/src/PolySpider/FileUploadUtils.py

日期格式

签名内容时的日期必须是RFC 1123的格式
__do_http_request方法里:

dt = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')

那么对于不同的Locale生成的字符串不相同:

一, 24  6 2013 06:25:37 GMT

于是请求签名失败了

AttributeError: 'UpYun' object has no attribute 'up_rest'

`
up = upyun.UpYun('_', secret='_*', endpoint=upyun.ED_AUTO)

with open('contentImg.jpg', 'rb') as f:
res = up.put('/style/xinu.jpg', f, checksum=True, need_resume=True)
`
一直 报错 :
AttributeError: 'UpYun' object has no attribute 'up_rest'

请教大神关于计算FORM API上传方式签名的问题

很抱歉在您百忙之中打扰您。

我希望使用SDK提供的【远程签名服务】,但需要计算出的签名是用于FORM API 。几经使用计算出来的签名总是被【signature error】,对照源码检查了半天也查不出哪里出错了。猜测可能policy这步问题比较大,不知道能否把计算policy的方法接口也开放了,可以直接提交相关参数然后得到FORM API的签名,而不必像现在如果需要FORM API 的签名,得自己实现policy之后传入。

或者,能否在auth_server.py提供一下FORM API的实现,我照着大神的写法排查下问题。

也阅读了SDK中policy的计算,但修改下用在python3下怎么也不好使。

headers['Content-Length']为int类型,导致无法上传

Windows, python 3.5.2, requests 2.11.0, upyun 2.3.5,像下面这样用upyun python sdk:

import upyun
up = upyun.UpYun(bucket=BUCKET, username=USERNAME, password=PASSWORD)
up.put('/upyun-python-sdk/ascii.txt', 'abcdefghijklmnopqrstuvwxyz\n')

会有异常

Traceback (most recent call last):
  File "R:\up\venv\lib\site-packages\requests\utils.py", line 752, in check_header_validity
    if not pat.match(value):
TypeError: expected string or bytes-like object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "R:\up\venv\lib\site-packages\upyun\modules\httpipe.py", line 59, in do_http_pipe
    timeout=self.timeout, files=files)
  File "R:\up\venv\lib\site-packages\requests\sessions.py", line 457, in request
    prep = self.prepare_request(req)
  File "R:\up\venv\lib\site-packages\requests\sessions.py", line 390, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "R:\up\venv\lib\site-packages\requests\models.py", line 295, in prepare
    self.prepare_headers(headers)
  File "R:\up\venv\lib\site-packages\requests\models.py", line 409, in prepare_headers
    check_header_validity(header)
  File "R:\up\venv\lib\site-packages\requests\utils.py", line 756, in check_header_validity
    "not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value 27 must be of type str or bytes, not <class 'int'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "upyun_test.py", line 5, in <module>
    up.put('/upyun-python-sdk/ascii.txt', 'abcdefghijklmnopqrstuvwxyz\n')
  File "R:\up\venv\lib\site-packages\upyun\upyun.py", line 91, in put
    headers, handler, params, secret)
  File "R:\up\venv\lib\site-packages\upyun\rest.py", line 87, in put
    h = self.__do_http_request('PUT', key, value, headers)
  File "R:\up\venv\lib\site-packages\upyun\rest.py", line 169, in __do_http_request
    value, headers, stream)
  File "R:\up\venv\lib\site-packages\upyun\modules\httpipe.py", line 81, in do_http_pipe
    raise UpYunClientException(e)
upyun.modules.exception.UpYunClientException: Header value 27 must be of type str or bytes, not <class 'int'>

应该是交给requests的Content-Length是int类型造成的……应该str一下吧

UnsupportedOperation - fileno

最近在使用django + 又拍云,但是直接网页上传文件的时候出现这个问题。先读取本地文件再上传就没问题。
代码大致是这样的,request.FILES["file"]是网页form上传来的。

up = Upload()
uploaded_file = request.FILES["file"]
#print os.fstat(uploaded_file.fileno()).st_size
file_path = up.upload_private_pic("/dealers/" + str(dealer.id) + "/images/", uploaded_file)
print file_path

Upload就是自己写的一个类,简单的集成了sdk中的上传文件的功能。但是sdk中有一句fileno的语句会导致错误,和我上面注释掉的那句基本一样。

截图在这里
http://photo.weibo.com/3560808645/albums/detail/album_id/3616760132684350#!/mode/1/page/1

usage BUG

发现bug一枚。当网络连接到需要认证的无线网络时,usage的返回值是网页内容,这显然是不合理的。

不知道2.2.0版本有没有注意到这个问题。

请用package的方式组织source code

把upyun sdk 用git submodule 加到project中,类似于这样子的目录结构

vendor/upyun

upyun不是用package的方式,导致没有办法直接通过

from vendor.upyun.upyun import UpYun

改版后不需要bucket了?

upyun.modules.exception.UpYunServiceException: ('329cdd4c0b4a1061c01c55081d2a00bb', 400, 'Bad Request', '{"msg":"need bucket name","code":40000003,"id":"329cdd4c0b4a1061c01c55081d2a00bb"}')

正常初始化,一直报错need bucket name

按照教程进行初始化:

up = upyun.UpYun('bucket','username','password',None,timeout=30,endpoint=upyun.ED_AUTO)
up.put('/test.txt', 'sdasdafsdafsdfasdfasd\n')

一直报如下错误:

raise UpYunServiceException(request_id, status, msg, err)
UpYunServiceException: ('fd4de16bc44ef869098584ce40485760', 400, 'Bad Request', u'{"msg":"need bucket name","code":40000003,"id":"fd4de16bc44ef869098584ce40485760"}')

bucket名称以及传入,却一直报错。

make_policy 方法的结果没有decode('utf-8'), 导致 服务器返回decode policy error

采用 .modules.sign模块下的make_policy方法获得policy 并且生成签名,上传文件时服务器报错decode policy error. 发现是由于make_policy的结果没有使用decode('utf-8'),导致结果带一个b前缀,造成服务端解码错误。测试将make_policy方法改为

def make_policy(data):
      policy = json.dumps(data);
      return base64.b64encode(b(policy)).decode()

可以成功调用。
另外在FormUpload类中的upload方法,data字典里的key 'service' 应该改为 'bucket'

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.