Skip to content

Commit

Permalink
Merge pull request #38 from CulturalMe/meteor-slingshot-34
Browse files Browse the repository at this point in the history
Tolerate missing file type.
  • Loading branch information
gsuess committed Jan 4, 2015
2 parents 8f3563b + b4c37d1 commit 32e1a64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 7 additions & 4 deletions lib/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @property {String} name
* @property {Number} size - File-size in bytes.
* @property {String} type - mime type.
* @property {String} [type] - mime type.
*
*/

Expand Down Expand Up @@ -198,17 +198,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 @@ -226,8 +226,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 @@ -281,8 +280,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 32e1a64

Please sign in to comment.