Wikipixel/openDAM — pull request #4 by ejucovy (2013-11-07 15:23:12+00:00)
Title: Uploader JS should use HTML5 standard Blob.slice if available; and fail loudly if no known slicing method ...

On my version of Chrome (Version 30.0.1599.101) the `Blob.webkitSlice` method does not exist. This causes file uploads to fail, because the `chunk` variable remains null, and this null value is sent to the server. The server then responds with a 404 after finding no value in the `$file` parameter.

This pull request fixes the issue in two ways:

* `Blob.slice` should be preferred over vendor-specific methods if it is available

* If no known slicing method (`.slice`, `.webkitSlice` or `.mozSlice`) is available in the browser, fail loudly with a Javascript error instead of passing a null file body to the server. With the current behavior, it took me a while to track down the problem. Failing early and loudly should make it much easier to debug and identify unsupported browsers.

(Per http://www.w3.org/TR/FileAPI/#slice-method-algo, `Blob.slice` is an HTML5 draft standard method and should be used if available. Per http://caniuse.com/#feat=fileapi this method should be widely available in recent browsers. For the deprecation / removal of `.webkitSlice` in recent versions of Webkit / Chrome see https://bugs.webkit.org/show_bug.cgi?id=96715)