Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
var fs = require('fs');
var filenames = fs.readdirSync(path);
filenames.forEach(function(filename) {
var postOptions = {
host: '',
port: '80',
path: '/services/upload/',
method: 'POST',
headers: {
'Content-Disposition': 'attachment; filename=' + $filename,
'Content-Type': 'application/octet-stream'
// open an HTTP request to Flickr (returns a stream)
var httpStream = http.request(postOptions, function(res) {
// dispose of the response status and body
// 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.on('end', function() {
console.log('Sent file ' + filename);

Should $filename be written like that or it's a leftover from php?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.