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

从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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据