transformation name with spaces causes 400 error

Offen
#42 4 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@const-cloudinary arbeitet bereits daran.

Seit 08.1.2019.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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}
Vorherrschende Sprache
Python
Sterne
262
Forks
133
Ø Merge
3 Min.
Gemergte PRs (30 T.)
1

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus cloudinary/pycloudinary

Alle Issues in cloudinary/pycloudinary

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.