Created
March 12, 2013 06:25
-
-
Save mikermcneil/5140760 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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