code: function(data) {
        var extras = {};
  
        if (data instanceof File) {
          extras = this.meta(data);
          data = data.toDataURL();
        }
        var parts = data.split(","), headers = parts[0].split(":"), body;
  
        if (parts.length !== 2 || headers.length !== 2 || headers[0] !== "data") {
          throw new Error("Invalid data URI.");
        }
        headers = headers[1].split(";");
        body = (headers[1] === "base64") ? atob(parts[1]) : decodeURI(parts[1]);
        var length = body.length, buffer = new ArrayBuffer(length), bytes = new Uint8Array(buffer);
  
        for (var i = 0; i < length; i++) {
          bytes[i] = body.charCodeAt(i);
        }
        return angular.extend(new Blob([bytes], { type: headers[0] }), extras);
      }
docs: Converts a File object or data URL to a Blob.