Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open PDF sent as multipart/form-data #307

Open
hirenshah opened this issue May 23, 2023 · 9 comments
Open

Cannot open PDF sent as multipart/form-data #307

hirenshah opened this issue May 23, 2023 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@hirenshah
Copy link

hirenshah commented May 23, 2023

I'm sending a PDF file as multipart/form-data and when I click download, for some reason it saves it as a .bin. The contents look like a PDF but also happen to have the following at the start:

--b4baaa6a-3ea0-4490-9026-e81849d841d2
Content-Type: application/pdf
Content-Disposition: form-data; name="document"; filename="01234567891011_Confirmation_Signed.pdf"; filename*=utf-8''01234567891011_Confirmation_Signed.pdf

And this at the end:

--b4baaa6a-3ea0-4490-9026-e81849d841d2--

Even after removing those parts, the PDF cannot be opened. File attached as a .txt because it wouldn't let me upload a .bin.

Am I missing something here?

3a8e6dfa-2c93-4f67-af74-dc485f091998.txt

@hirenshah
Copy link
Author

Not sure if it helps, but this is what happens when the same request is sent to webhook.site:

image

@tarampampam tarampampam added the bug Something isn't working label May 28, 2023
@tarampampam tarampampam self-assigned this May 28, 2023
@tarampampam
Copy link
Owner

I'm going to rewrite the UI completely, can you wait for that?

@hirenshah
Copy link
Author

I'm going to rewrite the UI completely, can you wait for that?

Of course 🙂

I'm not paying for this so it would just be rude if I did anything other than wait.

Do you have a rough time line in mind? Give me a shout if you need help with testing 👍

@tarampampam
Copy link
Owner

Not yet, most part of my time is spent at my regular job..

@hirenshah
Copy link
Author

hirenshah commented May 29, 2023

Not yet, most part of my time is spent at my regular job..

That is fine. This one isn't a big issue for me because the PDF is only being sent here for testing purposes.

The other two issues I raised were more significant:
#306
#308

I added comments to #308 as I spotted an issue with #306 and more with #308. If those could be fixed please, it would be much appreciated.

Also, can you drop me an email (my email address is visible in my profile) with details of how I can donate some £ for all your hard work 🙂

@tarampampam
Copy link
Owner

@hirenshah Great news - I’ve identified the reason why the downloaded file appeared broken. The issue was on the JS side, and in the v2 (which I’m actively working on), this will be resolved).

I expect to complete this in a few weeks, and I hope you’ll enjoy the new UI and new features ;)

Do not click here

image
image

@tarampampam
Copy link
Owner

tarampampam commented Nov 2, 2024

Could you test the early v2 build to ensure everything works as expected now?

The Docker image and precompiled binary files are available at this link: https://github.com/tarampampam/webhook-tester/releases/tag/v2.0.0-alpha1

@hirenshah
Copy link
Author

Running Alpha 4 and I posted a PNG using Postman. The download button writes all of the text you see to a file, which results in an invalid PNG. Removing first three lines and the last line fixes the file.

image

Ideally the filename value should be used when saving the file, as well as the boundary and content lines being removed.

It gets a little more complicated when multiple files and key/value pairs are posted as form-data. Each file would need to be saved separately, and text just ignored:

image

@tarampampam
Copy link
Owner

This is fine because the request body depends on what data you are sending and how you are sending it. For multipart requests, the server receiving the data determines how to interpret it. If you are only capturing the data being sent, you will need to handle it yourself. While this might seem a bit unusual, it can be very useful for debugging how the server constructs the multipart request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants