-
-
Save fzaninotto/f5e0a71b54c2329d5b50 to your computer and use it in GitHub Desktop.
This file contains 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
var fs = require('fs'); | |
var request = require('request'); | |
var apiUrl = 'http://api.flickr.com/services/upload/'; | |
var filenames = fs.readdirSync(path); | |
filenames.forEach(function(filename) { | |
// 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', function() { | |
console.log('Sent file ' + filename); | |
}); | |
}); | |
console.log('Finished!'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment