Possible to delay uploading until a promise is resolved?


I am wondering if it is possible to prevent the widget from starting uploads automatically. Basically I want the user to be able to select files for uploading, but not actually start the uploads until another button is clicked and a promise is resolved from it.

The use case is this: we want the user to attach a document to a new record. However, the underlying record does not yet exist (think a ‘create’ page). The idea is, the user can select the attachment, and when they press ‘submit’ and API call is made to create the new record. When the API response is received we now have the ID to which we want the upload associated. The upload can then be started, and when it is completed we can associate it to the created record using another API call.

The concern is that without this flow, a user could upload an attachment and then leave the page before submitting the new record. This would leave orphaned uploads in our storage (and some other orphaned data in our database that is implementation specific.) We want to encapsulate all of this creation into basically one button click, making sure things occur in the proper order.


By design, Uploadcare widget starts uploading immediately. There is no way to change this behavior. As a workaround, I can suggest to use standard HTML file input and upload files from it using uploadcare.fileFrom method. I made the demo to show how it works:


That is a great workaround. Thanks for the help!