Skip to content

Instantly share code, notes, and snippets.

@carlospliego
Created May 31, 2016 19:50
Show Gist options
  • Save carlospliego/48b1ece9a4d1ca8ca8423f39aecbdf9b to your computer and use it in GitHub Desktop.
Save carlospliego/48b1ece9a4d1ca8ca8423f39aecbdf9b to your computer and use it in GitHub Desktop.
FileProxy ( javaScript )
var FileProxy = function () {
this.stream = function (source, sourceHeaders, destinationHeaders, res) {
var rem;
res.writeHead(200, destinationHeaders);
rem = request(source, sourceHeaders);
rem.on('data', function (chunk) {
res.write(chunk);
});
rem.on('end', function () {
res.end();
});
}
};
var FP = new FileProxy();
FP.stream(url, {
method: "GET",
headers: {}
}, {'Content-Type': 'image/png'}, res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment