Skip to content

Instantly share code, notes, and snippets.

@davidworkman9
Last active December 22, 2015 09:59
Show Gist options
  • Save davidworkman9/6455758 to your computer and use it in GitHub Desktop.
Save davidworkman9/6455758 to your computer and use it in GitHub Desktop.
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);
}
}
@dennisharrison
Copy link

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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment