transformation name with spaces causes 400 error

Đang mở
#42 4 bình luận 0 reaction 1 người được giao Xem trên GitHub

@const-cloudinary đang làm issue này rồi.

Từ ngày 8/1/2019.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug

Making a call to get transformations, some of them come back with spaces in the name like this:

 {u'allowed_for_strict': False,
  u'name': u'fl_progressive,t_primary/t_t_primary@2x jpg.t_primary@2x jpg.display@2x',
  u'used': False},

Now trying to use that (ignoring issue #41 for now), generates a 400 server error:

In [10]: name = 'fl_progressive,t_primary/t_t_primary@2x jpg.t_primary@2x jpg.display@2x'

In [11]: cloudinary.api.transformation(name)
---------------------------------------------------------------------------
GeneralError                              Traceback (most recent call last)
<ipython-input-11-031ddf1dde0b> in <module>()
----> 1 cloudinary.api.transformation(name)

.../venv/lib/python2.7/site-packages/cloudinary/api.pyc in transformation(transformation, **options)
    129 def transformation(transformation, **options):
    130     uri = ["transformations", transformation_string(transformation)]
--> 131     return call_api("get", uri, only(options, "max_results"), **options)
    132
    133 def delete_transformation(transformation, **options):

.../venv/lib/python2.7/site-packages/cloudinary/api.pyc in call_api(method, uri, params, **options)
    225         # Error is parsing json
    226         e = sys.exc_info()[1]
--> 227         raise GeneralError("Error parsing server response (%d) - %s. Got - %s" % (response.code, body, e))
    228
    229     if "error" in result:

GeneralError: Error parsing server response (400) - . Got - No JSON object could be decoded

The fix it seems is to renencode the name using url encoding:

In [12]: name = 'fl_progressive,t_primary/t_t_primary@2x%20jpg.t_primary@2x%20jpg.display@2x'

In [13]: cloudinary.api.transformation(name)
Out[13]:
{u'allowed_for_strict': False,
 u'derived': [],
 u'info': [{u'flags': [u'progressive'], u'transformation': [u'primary']},
  {u'transformation': [u't_primary@2x jpg', u'display@2x']}],
 u'name': u'fl_progressive,t_primary/t_t_primary@2x jpg.t_primary@2x jpg.display@2x',
 u'used': False}
Ngôn ngữ chính
Python
Star
262
Fork
133
Merge trung bình
3 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cloudinary/pycloudinary

Tất cả issue của cloudinary/pycloudinary

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.