Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolerate missing file type. #38

Merged
merged 3 commits into from
Jan 4, 2015
Merged
Show file tree
Hide file tree
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
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