Skip to content

Instantly share code, notes, and snippets.

@fzaninotto
Created June 17, 2012 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fzaninotto/2945620 to your computer and use it in GitHub Desktop.
Save fzaninotto/2945620 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var request = require('request');
var async = require('async');
var apiUrl = 'http://api.flickr.com/services/upload/';
var filenames = fs.readdirSync(path);
async.forEach(filenames, function(filename, callback) {
// open a file stream on the local image
var fileStream = fs.createReadStream(path + filename);
// read from the file and write to the HTTP request
fileStream.pipe(request.post(apiUrl));
fileStream.on('end', callback);
}, function(err) {
console.log(err ? err.message : 'Finished!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment