Upload widget never finishes or calls callbacks


#1

I have a document editor that uses VueJS and I want to programatically open an upload widget, then get the file URL when the upload is done. This was pretty trivial to set up BUT it doesn’t work at all.

I’m loading uploadcare via CDN:

<script type="text/javascript">
  UPLOADCARE_LIVE = false; // I do not need you polling my page.
  UPLOADCARE_TABS = "file url";
  UPLOADCARE_PUBLIC_KEY = "...";
</script>
<script src="https://ucarecdn.com/libs/widget/3.3.0/uploadcare.full.min.js" charset="utf-8"></script>

I have a button to insert an image in a document, the click handler function is as follows:

var fileInput = document.createElement('input');
var widget = uploadcare.Widget(fileInput);
widget.onUploadComplete(function(info) {
  console.log("File info!", info);
});
widget.openDialog();

When I click the button the widget appears, it takes a file, it uploads the file, and the file upload IS SUCCESSFUL. In the network tab I can see the progress and see it finishes. I can see the file in my uploadcare dashboard.

But that callback function never fires, and the upload care visual aid never completes either, eg it just gets stuck looking like this: Screen Shot 2018-06-15 at 9.33.21 PM.png

There are no console errors.

I’ve tried everything under the sun and as far as I can tell the widget code itself is broken, because everything else works perfectly. The callback just never fires.

Can you guys help?


#2

Hi Andrew!

The provided code snippet is correct. Moreover, I ran it on codepen and the onUploadComplete callback works properly. You can check this here: An Anonymous Pen on CodePen

Can you reproduce the issue on codepen, jsfiddle, etc. so I could look into it?