Upload file directly to Azure Blob Storage (with SAS) using dropzone.js
<p>I would like to use dropzone.js to upload files directly to Azure Blob Storage, with SAS (<a href="https://azure.microsoft.com/en-gb/documentation/articles/storage-dotnet-shared-access-signature-part-2/#part-1-create-a-console-application-to-generate-shared-access-signatures" rel="noreferrer">example here</a>) to keep the files private.</p>

<p>As I understand it, the workflow would be:</p>

<ol>
<li>The user chooses a file</li>
<li>The dropzone  <code>processing</code> 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</li>
<li>The dropzone upload URL is set to the "secured" blob URL</li>
<li>The upload begins</li>
</ol>

<p>I have found the following wiki article showing how to set the dropzone URL dynamically (<a href="https://github.com/enyo/dropzone/wiki/Set-URL-dynamically" rel="noreferrer">https://github.com/enyo/dropzone/wiki/Set-URL-dynamically</a>)</p>

<pre><code>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";
    });
  }
};
</code></pre>

<p>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 <strong>asynchronously</strong>?</p>

<p>Thanks</p>