我正在开发一个Backbone项目,以及一个在psql数据库上读取的koa / node后端。我设置了一个应该指向PDF文件的get路由,我希望每个都获得base64加密字符串。我得到了这个对象:
{"0":37,"1":80,"2":68,"3":70,"4":45,"5":49,"6":46,"7":51,"8":10,"9":37,"10":196,"11":229,"12":242,"13":229,"14":235,"15":167,"16":243,"17":160,"18":208,"19":196,"20":198,"21":10,"22":52,"23":32,"24":48,"25":32,"26":111,"27":98,"28":106,"29":10,"30":60,"31":60,"32":32,"33":47,"34":76,"35":101,"36":110,"37":103,"38":116,"39":104,"40":32,"41":53,"42":32,"43":48,"44":32,"45":82,"46":32,"47":47,"48":70,"49":105,"50":108,"51":116,"52":101,"53":114,"54":32,"55":47,"56":70,"57":108,"58":97,"59":116,"60":101,"61":68,"62":101,"63":99,"64":111,"65":100,"66":101,"67":32,"68":62,"69":62,"70":10,"71":115,"72":116,"73":114,"74":101,"75":97,"76":109,"77":10,"78":120,"79":1,"80":149,"81":86,"82":203,"83":114,"84":26,"85":89,"86":12,"87":221,"88":247,"89":87,"90":104,"91":118,"92":120,"93":145,"94":235... }
有没有人见过PDF文件的这种表示?如何将此数据作为常规PDF文件恢复?
感谢您的帮助!
答案 0 :(得分:1)
这看起来像是一种非常破碎的方式来从数据库中获取东西。你的对象是一对{position:byte},因为Python提示第一项是PDF标题的一部分:
>>> [chr(i) for i in [37, 80, 68, 70, 45, 49, 46, 51]]
['%', 'P', 'D', 'F', '-', '1', '.', '3']
由于你没有指定任何库/代码,我不能提供任何直接的建议,但你应该检查你的数据库真正包含的内容(这应该是二进制数据的BLOB,而不是base64或疯狂的JSON)以及如何使用您选择的库从数据库中获取原始二进制数据。