Last active
December 22, 2015 09:59
-
-
Save davidworkman9/6455758 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function read_a_file_and_replace_x_with_smilies (filePath) { | |
// Set up a future | |
var fut = new Future(); | |
fs.readFile(filePath, function (err, data) { | |
if (err) fut.return({ error: err }); | |
doImageMani(data, function (err) { | |
if (err) fut.return({ error: err }); | |
// everythings done, no need to return anything | |
fut.return(); | |
}); | |
}); | |
var error = fut.wait(); | |
if(error) { | |
throw(error.error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
write_future.return(fs.writeFile(path + name, blob, encoding, function(err) {
if (err) {
console.log(err);
throw (new Meteor.Error(500, 'Failed to save file.', err));
} else {
console.log('The file ' + name + ' (' + encoding + ') was saved to ' + path);
}
}));
return write_future.wait(Media.insert(media_item));