How do I get CDN URL of uploaded file?

If you use our file uploader (widget), you might need to get a URL of the file once it has been uploaded to save it to your database, CMS, or render a preview. The JS API of the widget allows you to do this using the onUploadComplete method:

// get a widget reference
const widget = uploadcare.Widget('[role=uploadcare-uploader]');

// listen to the "upload completed" event
widget.onUploadComplete(info => {
  // get CDN URL from file/group information object. Here you can generate a thumbnail using the file URL, save the URL to DB, etc.

Check out a live demo on CodePen.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.