I am trying to upload a large file (1.5 GB) in Amazon S3 using REST Api and HTML5. Here's what the download code looks like (code is removed for readability):
File.prototype.slice = File.prototype.webkitSlice || File.prototype.mozSlice || File.prototype.slice; var length = u.settings.chunk_size; // 6MB var start = chunk * length; var end = Math.min(start + length, u.file.size); var xhr = new XMLHttpRequest(); var path = "/" + u.settings.key; path += "?partNumber=" + chunk + "&uploadId=" + u.upload_id; var method = "PUT"; var authorization = "AWS " + u.settings.access_key + ":" + signature; var blob = u.file.slice(start, end); xhr.upload.addEventListener("progress", progress_handler, true); xhr.addEventListener("readystatechange", handler, true); xhr.addEventListener("error", error_handler, true); xhr.addEventListener("timeout", error_handler, true); xhr.open(method, u.settings.host + path, true); xhr.setRequestHeader("x-amz-date", date); xhr.setRequestHeader("Authorization", authorization); xhr.setRequestHeader("Content-Type", u.settings.content_type); xhr.setRequestHeader("Content-Disposition", "attachment; filename=" + u.file.name); xhr.send(blob);
chunk_size is 6 MB. After the piece finishes loading, the next next, etc. But sometimes (every 80 pieces or so) the PUT request fails, with e.type == "error" , e.target.status == 0 (which surprises me) and e.target.responseText == "" . After a fragment fails, the code tries to load it again and receives the same error. When I refresh the page and continue loading (the same piece!), It works like a charm (80 pieces or so when it gets stuck again). Here's how the request looks in chrome dev tools:



Any ideas why this might happen, or how to debug something like this?
EDIT: Here is the OPTIONS answer:

source share