Skip to content

Instantly share code, notes, and snippets.



Created Sep 14, 2016
What would you like to do?
var async = require("async"),
Kraken = require("kraken"),
fs = require("fs");
var kraken = new Kraken({
api_key: "your-api-key",
api_secret: "your-api-secret"
var yourArray = [
async.forEach(yourArray, 10, function (filePath, cb) {
// here you process your files with concurrency of 10 at a time
var opts = {
file: fs.createReadStream(filePath),
wait: true
kraken.upload(opts, function (data) {
if (data.success) {
console.log('Success. Optimized image URL: %s', data.kraked_url);
} else {
console.log('Fail. Error message: %s', data.message);
// this is very important. Calling this callback (cb) tells async
// that this async function is now complete so it can process another one
}, function (err) {
if (err) {
// this is a final callback called only once
// when all files have been processed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.