doujiushi9007 2019-03-29 13:08
浏览 748
已采纳

从MySQL中的BLOB读取pdf内容

i have developed a system which parses and stores emails into a MySQL database. I save the attachments as an array of objects in JSON into a MEDIUMBLOB field. Everything works almost as expected. At least when saving. When i try to read the attachments i only get back the images, but not the pdf file.

The BLOB has the following 'dummy' content:

[
{
"filename":"img1.png", "ext":"png", "type": "image/png", "size":4096, 
"dispo":"inline", "cid":"123@abc", "content":"base64_encoded binary- 
data"
},
{
"filename":"pdf1.pdf", "ext":"pdf", "type": "application/pdf", 
"size":4096, "dispo":"attachment", "cid":null, 
"content":"base64_encoded binary-data"
}
]

The attachments are written as follows: json_encode($attachmentsDB,JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).

I debugged, but somehow when i fetch data BLOB from the DB - in this case - the last element = the pdf-file is not returned. Only the preceding image files.

When i hardcode the data and try my code it works perfectly. The data isn't truncated either.

It seems that it's not a memory problem

If anybody could give me a hint please... ?

Many thanks in advance

  • 写回答

2条回答 默认 最新

  • dqellle310167 2019-03-30 06:46
    关注

    many thanks @Shadow ! i modified the field to LONGBLOB and now it seems to work fine! :-)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL