Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Created March 12, 2013 06:25
Show Gist options
  • Select an option

  • Save mikermcneil/5140760 to your computer and use it in GitHub Desktop.

Select an option

Save mikermcneil/5140760 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var knox = require('knox');
var request = require('request');
var uri = "https://lh4.ggpht.com/N5f6FA5zPjrTH-UggaFLstYSO1za-01CbsO17ZwkghtF0k9TSzWcnCn4bybCDeIOP4cu=w124";
// Open download stream from google
var downStream = request(uri);
// Open temp file ("upload" stream)
// var tempFile = fs.createWriteStream('stupidTempFile.png');
var upStream = knox.createClient({
key: 'AKIAILI5SA5VKWYWVENQ',
secret: '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',
bucket: 'game-icons'
});
// Use crazy knox syntax to pipe downstream to upstream
upStream.putStream(downStream, './test.png', {
'Content-Type': 'image/png'
}, function(err, res){
if (err) console.error(err);
else console.log('Success');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment