Skip to content

Instantly share code, notes, and snippets.

@robi42
Created March 6, 2011 14:56
Show Gist options
  • Save robi42/857344 to your computer and use it in GitHub Desktop.
Save robi42/857344 to your computer and use it in GitHub Desktop.
var http = require('ringo/httpclient');
var {AsyncResponse} = require('ringo/webapp/async');
var app = exports.app = require('stick').Application()
.configure('error', 'notfound', 'route', 'params');
app.get('/proxy/*', function (req, path) {
var response = new AsyncResponse(req);
// Fetch MP3 from AWS S3.
http.request({
url: 'http://s3.amazonaws.com/acme/' + path + '?' + req.queryString,
async: true,
binary: true,
part: function (bytes) {
response.write(bytes).flush();
},
complete: function () {
response.close();
}
});
return response.start(200, {'Content-Type': 'audio/mpeg'});
});
if (require.main === module) {
require('stick/server').main(module.id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment