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

Stream not work correctly #3063

Open
i-fire1773 opened this issue Sep 6, 2023 · 2 comments
Open

Stream not work correctly #3063

i-fire1773 opened this issue Sep 6, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@i-fire1773
Copy link

Stream not correct work for video/image
I use project
VaporUploads-main.zip
When I send file type pdf it work correct? and I can open it, but when I send other type of file it send, but I can't open it because
image
image file I download from internet

@i-fire1773 i-fire1773 added the bug Something isn't working label Sep 6, 2023
@vzsg
Copy link
Member

vzsg commented Sep 6, 2023

There's nothing wrong with Vapor or your project, but the way you upload the image is not compatible with the code. The route expects a HTTP POST request whose body is the image data directly, not part of a multipart form.


Opening the image file in a hex editor quickly reveals the issue. Notice the highlighted area: that's the header from a multipart file upload, which was saved into the image file directly.

image

If I delete this, and the footer area at the end, the image opens up fine (although there don't seem to be any rabbits on it).


Now, how to do multipart uploads without loading the complete body into memory is an interesting challenge for which I don't have an answer. Maybe someone else will.

@Joannis
Copy link
Member

Joannis commented Sep 6, 2023

@vzsg Multipart should in theory be streamable, but it's not currently supported. The caveat is that you'll need to consume the parts in order.

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

3 participants