i want to download a pdf which is present in datapower local directory i created a serice and wrote a small gateway script but the pdf in downloading in unreadable format i want the pdf to be downloaded in .pdf format
var urlopen = require('urlopen');
var fs = require('fs');
urlopen.open("local:///pdf.pdf", function (error, response) {
if (error) {
session.output.write("openCallback error: " + error.errorMessage+"\n");
}
else {
if (response.statusCode == 200) {
// You have a 200, so you can read the file
fs.readFile("local:///pdf.pdf", function(error,data) {
session.output.write(data);
});
}
}
});