Skip to content

Commit

Permalink
Merge pull request #39 from CulturalMe/blob-upload
Browse files Browse the repository at this point in the history
#22: Allow uploads for Blob.
  • Loading branch information
gsuess committed Jan 5, 2015
2 parents 32e1a64 + d129e8e commit 688face
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
7 changes: 4 additions & 3 deletions lib/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 688face

Please sign in to comment.