I would like to use dropzone.js to upload files directly to Azure Blob Storage, with SAS (example here) to keep the files private.
As I understand it, the workflow would be:
- The user chooses a file
- The dropzone
processing
event fires. In the event handler, I call a method on my site's API which creates an Azure Blob URI to upload to, including the SAS query string - The dropzone upload URL is set to the "secured" blob URL
- The upload begins
I have found the following wiki article showing how to set the dropzone URL dynamically (https://github.com/enyo/dropzone/wiki/Set-URL-dynamically)
Dropzone.options.myDropzone = {
init: function() {
this.on("processing", function(file) {
// I need to do an async call here, to get the URL...
this.options.url = "/some-other-url";
});
}
};
The problem is that the above example is synchronous. How can I delay the upload until the URL has been requested from my web api asynchronously?
Thanks