diff --git a/lib/directive.js b/lib/directive.js index 25986d5..bf059b3 100644 --- a/lib/directive.js +++ b/lib/directive.js @@ -36,7 +36,7 @@ /** * @typedef {Object} FileInfo * - * @property {String} name + * @property {String} [name] - Given name to the file. * @property {Number} size - File-size in bytes. * @property {String} [type] - mime type. * @@ -145,7 +145,8 @@ _.extend(Slingshot.Directive.prototype, { getInstructions: function (method, file, meta) { var instructions = this.storageService().upload(method, _.extend({ - contentDisposition: "inline; filename=" + quoteString(file.name, '"') + contentDisposition: file.name && "inline; filename=" + + quoteString(file.name, '"') }, this._directive), file, meta); check(instructions, { @@ -202,7 +203,7 @@ Meteor.methods({ check(type, String); return !type || /^[^\/]+\/[^\/]+$/.test(type); })), - name: String, + name: Match.Optional(String), size: Match.Where(function (size) { check(size, Number); return size >= 0; diff --git a/lib/upload.js b/lib/upload.js index b5b27df..3bd59a7 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -80,19 +80,14 @@ Slingshot.Upload = function (directive, metaData) { }, /** - * @param {File} file + * @param {(File|Blob)} file * @param {Function} [callback] * @returns {Slingshot.Upload} */ send: function (file, callback) { - if (window.chrome && window.navigator.vendor === "Google Inc.") { - check(file, window.File); - } else { - // not Google chrome - if (! (file instanceof window.File)) - throw new Error("Not a file"); - } + if (! (file instanceof window.File) && ! (file instanceof window.Blob)) + throw new Error("Not a file"); self.file = file;