0
votes

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?

1
async is a reserved Python keyword now. The API lib seems to be older than that. - Klaus D.
@KlausD. ahhhhhh that makes a lot of sense! Hmmm...I wonder what I should use instead :L - p4t

1 Answers

0
votes

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