I have an issue with pdf encoding on heroku. I have been looking for hours but I haven't seen anything similar...
I made a node JS script which sends put request with a pdf to another node server.
var formData = {
custom_file: {
value: myReadStream,
options: {
filename: filename,
contentType: 'application/pdf'
}
}
}
request.put({url : "http://myapp.herokuapp.com", formData : formData}, (err,res,body)=>{
if(err) console.log(err);
else console.log(body);
});
And I have my server which store the file :
let output = fs.createWriteStream(path + "/myPdf.pdf")
req.pipe(output);
output.on('finish',()=>{
console.log("uploaded");
});
Everything is working fine with my local server. I can use another script to download the file. The problem is when I push my server on heroku, the pdf is uploaded without error but when I download it, it's full of weird characters like this :
----------------------------320961239457907103894868
Content-Disposition: form-data; name="custom_file"; filename="test.pdf"
Content-Type: application/pdf
%PDF-1.5
%ø˜¢˛
2 0 obj
<< /Linearized 1 /L 29161 /H [ 687 127 ] /O 6 /E 28886 /N 1 /T 28885 >>
endobj
and like this
<< /Filter /FlateDecode /Length 3187 >>
stream
xú≠\€é$∑
}üØËÁ�ñu!) Ϩ3~N∞@> ±v�;ˇÑRÈZ”Ε∏fi¡ŒtW˜°(ä‚M¨rÀ?fl8˛ï¿=˛˘ÀÀØ/Â
f‡÷§Hòø˝Úè?=˛Àüô…9õB≈ÌÔÏÂÁÔfl?Æø˝ÙÚ̘ˆÒ”ˇ*Õ»4ùÛP»˝¯‰ fl¯Á◊ó:r»&$.
ó˙fi>~Æfl/øÁg?flæ˚ÛÀøˇ@6}g3”u…˙89∑}Ω`ÙÎßóoflÏ#Ä°Ú/=>˝¯‚¶dÌ„”//Äfl~˝Ø«ü≠ıoy|
If anyone has an idea I'll be glad to test it! Have a nice day :)
via Loïc Combis
No comments:
Post a Comment