what is wrong with this binary file transfer (corrupting docx files)?

前端 未结 1 1871
醉话见心
醉话见心 2021-01-21 17:44

I\'ve been trying to resolve this issue for over a week and could really do with some help.

We are using a httprequest to post files to an api. Most fi

相关标签:
1条回答
  • 2021-01-21 18:16

    Here is what I tried to do with your docx:

    • I opened them with word, the corrupted one was indeed corrupt
    • I unzipped the files, they were fully identical

    I watched at the size of the docx, it was different for the docx.

    So I looked into the binary file: The beginning of the file is identical

    504b 0304 1400 0600 0800 0000 2100 ddfc
    9537 6601 0000 2005 0000 1300 0802 5b43
    6f6e 7465 6e74 5f54 7970 6573 5d2e 786d
    6c20 a204 0228 a000 0200 0000 0000 0000
    

    But at then end:

    Uncorrupted file

    6f72 642f 7374 796c 6573 2e78 6d6c 504b
    0506 0000 0000 0b00 0b00 c102 0000 ed24
    0000 0000 
    

    Corrupted file

    6f72 642f 7374 796c 6573 2e78 6d6c 504b
    0506 0000 0000 0b00 0b00 c102 0000 ed24
    0000 0000 0a2d 2d2d 2d2d 2d2d 2d2d 
    

    As you can see, they is a sequence: 0a2d 2d2d 2d2d 2d2d 2d2d. The rest of the file is identical. And when I delete this sequence, the file is not corrupted any more.

    Converted into ascii, 0a2d 2d2d 2d2d 2d2d 2d2d is \n----

    This is probably due to the strRequestEnd = vbCrLf & "--" & strBoundary & "--"

    Howewer, as I don't really understand exactly what happens into your code, If you want more help, please explain more deeply this portion of code.

    Hope this helps

    0 讨论(0)
提交回复
热议问题