I can successfully retrieve my OPT file from AWS using Knox.. but when I go to use the file it is broken. I believe this is an encoding issue.. but honestly I'm not sure.
The end file size is larger than the files actual size.
Below is a simplified example:
var client = knox.createClient({
key: '************',
secret: '************',
bucket: '************'
});
client.get(otfFile).on('response', function(res){
var file = "";
res.setEncoding("binary");
res.on('data', function(chunk){
file += chunk;
});
res.on('end', function() {
// Save File
fs.writeFile( filepath, file, function(err) {
if (err) console.error(err);
});
});
}).end();
Do you know how to fix it or have an idea as to what is wrong?