-
-
Save oberhamsi/857360 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 http = require('ringo/httpclient'); | |
var {defer} = require('ringo/promise'); | |
var {MemoryStream} = require('io'); | |
var {AsyncResponse} = require('ringo/webapp/async'); | |
var app = exports.app = require('stick').Application() | |
.configure('error', 'notfound', 'route', 'params'); | |
app.get('/proxy/*', function (request, path) { | |
var response = new AsyncResponse(request); | |
// Fetch MP3 from AWS S3. | |
http.request({ | |
url: 'http://localhost/Music/test.mp3', | |
async: true, | |
binary: true, | |
part: function (bytes) { | |
response.write(bytes); | |
response.flush(); | |
} | |
}); | |
response.start(200, { | |
'Accept-Ranges': 'bytes', | |
'Content-Type': 'audio/mp3' | |
}); | |
return response; | |
}); | |
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