Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions meteor-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,29 @@ if (Meteor.isClient) {
upload: function (file, method, options, callback) {
var self = this;

if (!Blob.prototype.isPrototypeOf(file))
throw new Meteor.Error("First parameter must inherit from Blob");

if (!_.isString(method))
throw new Meteor.Error("Second parameter must be a Meteor.method name");

if (arguments.length < 4 && _.isFunction(options)) {
callback = options;
options = {};
}

var error = null;
if (!Blob.prototype.isPrototypeOf(file)) {
error = new Meteor.Error(400, "First parameter must inherit from Blob");
}

if (!_.isString(method)) {
error = new Meteor.Error(400, "Second parameter must be a Meteor.method name");
}

if (error) {
if (callback) {
return callback(error);
}
else {
throw error;
}
}

options = options || {};
self.rewind();
self.size = file.size;
Expand Down