Lazy async moderation / Retrigger moderation

Options
rod
rod Member Posts: 1
edited August 2023 in Developer APIs

I want to use Amazon Rekognition plugin in the following way:

  • User uploads photo to Cloudinary and moves on using the site;
  • Cloudinary lazily moderates the uploaded photo asynchronously;
  • When finished, Cloudinary sends the results to a server endpoint via webhook;
  • Server does further processing.

But right now, if I use `auto moderation: aws_rek......` the client is waiting for moderation and getting a rejected result in sync when uploading.

Is there a way to just upload without a check and then do this in the background?

There is also a scenario where the user could "update" a photo. Is there an api call to "retrigger" the moderation and get the results in the webhook handler?

Thanks!

Answers

  • DannyFromCloudinary
    DannyFromCloudinary Member, Cloudinary Staff Posts: 98
    Options

    Hi @rod. Danny from Cloudinary Support here.

    You can perform the moderation in the background by setting the async parameter to true in the upload call. This is listed in the optional parameters here in the Upload API docs, and there are examples showing how to use Rekognition in various languages here. In Node though, you would want to try something like this:

    cloudinary.v2.uploader
    .upload("local_file.jpg", 
      {moderation: "aws_rek",
      async: true})
    .then(result=>console.log(result));
    

    You could then use a Global Notification URL or use a notification URL specifically for this API request to then handle the result of the moderation programatically.

    With regards to updating a photo, you could use the explicit method of the Upload API to trigger the moderation once again.

    I hope this helps, but if you do have any remaining questions, please let me know and I'll do my best to assist.

    Many thanks,

    -Danny