Note that there are some explanatory texts on larger screens.

plurals
  1. POS3 browser upload via POST: unable to handle errors gracefully
    primarykey
    data
    text
    <p>I am writing an app where I want the customer to be able to upload to Amazon S3 straight from the browser. I can make this work just fine. But when errors occur, I want to handle them more gracefully than splattering an XML document on the customer's screen.</p> <p>I have a scheme that I think would work, but it's failing. Here's what I'm trying:</p> <ol> <li>Create a form to do the upload, and store the form on S3 itself, in the same domain as the "action" attribute of the form.</li> <li>Redirect the customer to this form. Now their browser is sitting on <a href="https://&lt;bucket&gt;.s3.amazonaws.com/something" rel="nofollow noreferrer">https://&lt;bucket&gt;.s3.amazonaws.com/something</a>.</li> <li>The page contains a hidden iframe. The form sets its target to the iframe.</li> <li>The load event handler looks at the contents of the iframe, and acts upon it.</li> </ol> <p>So, something like this:</p> <pre><code>&lt;iframe id="foo" name="foo" style="display: none" /&gt; &lt;form target="foo" action="https://&lt;bucket&gt;.s3.amazonaws.com/"&gt; &lt;input type="hidden" name="..." value="..." /&gt; &lt;input type="file" name="file" /&gt; &lt;/form&gt; </code></pre> <p>with this javascript (using jquery):</p> <pre><code>function handler() { var message = $("#foo").contents().find('message').text(); alert(message); } $("#foo").load(handler); </code></pre> <p>Using firebug, I can see that the iframe contains an XML document, that contains a "message" node. However, the <code>.find('message')</code> always fails to find anything within the XML document.</p> <p>Notice that the action of the form has the same domain, port, and scheme as the document itself. So, I don't think that I should be running afoul of the same-origin policy. Right? But it fails every time. This is using Firefox and Google Chrome browsers.</p> <p>Thanks for any advice!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload