1

I am trying to asynchronously upload images to Cloudinary using their Python API.

Their documentation states the following is required to upload an image.

result = cloudinary.uploader.upload(file, **options)

Since, I would like to upload asynchronously, it appears I need to set the "async" option to True (also in the documentation).

async (Boolean): Tells Cloudinary whether to perform the upload request in the background (asynchronously). Default: false.

Since options has **, as explained in this SO post, I assume that the function accepts keyword arguments like so.

response = await cloudinary.uploader.upload(img, async=True)

However, when I run my script, I get the following error:

  File "async_upload.py", line 16
    response = await cloudinary.uploader.upload(img, async=True)
                                                         ^ SyntaxError: invalid syntax

How do I upload multiple images asynchronously in Cloudinary?

ptk
  • 6,835
  • 14
  • 45
  • 91

1 Answers1

0

There isn't a specific Cloudinary method. You can use asyncio to upload asynchronously. https://medium.freecodecamp.org/a-guide-to-asynchronous-programming-in-python-with-asyncio-232e2afa44f6

Matt Greene
  • 424
  • 2
  • 3
  • I believe cloudinary.uploader.upload(img) without the async flag is a blocking function therefore using asyncio with the synchronous function call will not lead to any performance improvement over my existing synchronous solution. – ptk Aug 01 '18 at 13:10