Trigger and wait video processing from the dialog/widget

Hello, I am using the upload widget and I’d like to trigger and wait for video processing after a video is successfully uploaded.
Is there a common flow t manage that?

So far, I think I found a way but not sure it is ideal…

dialog.fileColl.onAdd.add(file => {
      file.progress(progressInfo => {
        // If state === ready 
        // -> trigger the video processing
        // -> display a loading overlay 
        // -> once processing finished, hide overlay
        // then set the new file in the dialog?
      });
    });

Any feedback on this?

Thanks

Hi @luke-acquire, sorry for the delay! I’d suggest against going this way as the file.progress callback is called multiple times while the file is being uploaded. Using file.done should work better, but I’d recommend you add a file type check as well

dialog.fileColl.onAdd.add((file) => {
  file.done((fileInfo) => {
    if (fileInfo.mimeType.contains("video")) {
      // -> trigger the video processing
      // -> display a loading overlay
      // -> once processing finished, hide overlay
      // then set the new file in the dialog?
    }
  });
});

Also, we recommend that you never make requests to the REST API directly from your frontend, as these requests include authentication credentials (secret key or signature). Instead of making a request directly to the API, your app should make a request to your backend that proxies the request to our REST API. This ensures that your secret key/signature will not be exposed.

Thank you Alex, works like a charm. Of course, I’m not calling the API directly from the front :slight_smile:

1 Like