Skip to content

Commit

Permalink
#34: Added tolerance to unknown file types.
Browse files Browse the repository at this point in the history
  • Loading branch information
gsuess committed Jan 4, 2015
1 parent ffa2209 commit f6630f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 8 additions & 4 deletions lib/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Slingshot = {};
*
* @property {String} name
* @property {Number} size - File-size in bytes.
* @property {String} type - mime type.
* @property {String} [type] - mime type.
*
*/

Expand Down Expand Up @@ -148,6 +148,7 @@ _.extend(Slingshot.Directive.prototype, {
*
* @throws Meteor.Error
*
* @param {Object} method
* @param {FileInfo} file
* @param {Object} [meta]
*
Expand Down Expand Up @@ -255,17 +256,20 @@ Meteor.methods({
"slingshot/uploadRequest": function (directiveName, file, meta) {
check(directiveName, String);
check(file, {
type: Match.Where(function (type) {
type: Match.Optional(Match.Where(function (type) {
check(type, String);
return /^[^\/]+\/[^\/]+$/.test(type);
}),
return !type || /^[^\/]+\/[^\/]+$/.test(type);
})),
name: String,
size: Match.Where(function (size) {
check(size, Number);
return size >= 0;
})
});

if (!file.type)
delete file.type;

check(meta, Match.Optional(Match.OneOf(Object, null)));

var directive = Slingshot.getDirective(directiveName);
Expand Down
5 changes: 1 addition & 4 deletions lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ Slingshot.Upload = function (directive, metaData) {
var download = self.instructions.download;

if (preload && preloaded.get() !== download) {
preloadImage(download, function (event) {
console.log(event);
preloadImage(download, function () {
preloaded.set(download);
});
}
Expand Down Expand Up @@ -256,8 +255,6 @@ Slingshot.Upload = function (directive, metaData) {
*/

function preloadImage(image, callback) {
console.log("preloading", image);

var preloader = new window.Image();

preloader.onload = callback;
Expand Down

0 comments on commit f6630f0

Please sign in to comment.