Suspecting the Frontend Component Corrupted My Excel File, How to Prove It
Background
I’m working on a requirement where users upload files through an Excel file upload, with each row in the Excel file representing a data entry to be processed in batch on the backend. Since the data provided by users might contain errors, I plan to perform a validation check on the backend and add a column to each row to indicate any issues with it.
Initially, I thought of returning a list (in JSON format), where each item represents a row of data, and simply display it on the interface.
But then, I wondered if it could work by directly returning an Excel file instead?
It seems possible.
/>
Ultimately, it goes like this: receive a file, perform the check, and return the original file with an added column containing the check results.
However, the frontend Vue component being used renders it with issues; the downloaded file with results appears garbled or corrupted.
/>
So, I wanted to see if there was an issue with the returned binary data.
Testing Method
I called that interface, and since it was local testing, I used Wireshark locally to capture packets. The following is the returned packet, representing the several layers of the computer network from top to bottom: physical layer/data link layer/IP/TCP/HTTP.
What’s behind HTTP? As you can see, Wireshark kindly provides preliminary analysis, revealing that it’s an XLS file format. You can also see that this binary stream is approximately 23,040 bytes.
With the binary data available, the next step is to convert this binary into an XLS file to check for any issues. Actually, a normal file download interface allows you to download directly through the browser. But in my case, the frontend component is rather peculiar; it seems to perform another layer of conversion after obtaining the binary, leading to issues with the file I receive.
That’s why I thought of testing the binary data before conversion first.
Here’s the simplest method directly:
What then?
That’s pretty much it.
I also tried editing the file using a hex editor, but it was more cumbersome, so I gave up.
Additionally, if you want to compare binaries, you can use software like Beyond Compare.