title: How can I avoid "Networking Error: Network Failure" when downloading a file from AWS S3 bucket?
body: <p>I am using AWS S3 to access a file in my HTML5 application. Following code works fine on my laptop but it fails on the mobile device (iphone). Any help is greatly appreciated.</p>
  
  <pre><code> AWS.config.region = 'us-west-2';
   var bucket = new AWS.S3({params: {Bucket: 'mybucket'}});
   bucket.getObject({Key: myfile}, function (error, data) {
  
   if (error != null) {
      alert("Failed to retrieve " + myfile + " :" + error);
   } else {
       //alert("Loaded " + data.ContentLength + " bytes");
       localStorage[myfile] = data.Body.toString();
       // do something with data.body
  
   }}); 
  </code></pre>
  
  <p>The error I get is:
      "http //local host
      Failed to retrieve foo.json :NetworkingError: Network Failure"</p>
  
  <p>I have the followings CORS configuration for this bucket</p>
  
  <pre><code>&lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;
  &lt;CORSRule&gt;
      &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
      &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
      &lt;MaxAgeSeconds&gt;3000&lt;/MaxAgeSeconds&gt;
  &lt;/CORSRule&gt;
  </code></pre>
  
  <p></p>