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

Content-Type assumption not done if the file don't have extension #567

Closed
ReiatsuSan opened this issue Jul 19, 2023 · 4 comments · Fixed by #568
Closed

Content-Type assumption not done if the file don't have extension #567

ReiatsuSan opened this issue Jul 19, 2023 · 4 comments · Fixed by #568

Comments

@ReiatsuSan
Copy link

ReiatsuSan commented Jul 19, 2023

PHP version: x.y.z (hint: php --version)

Description
There is an issue within psr7 in the MultipartStream class inside createElement method (https://github.com/guzzle/psr7/blob/815698d9f11c908bc59471d11f642264b533346a/src/MultipartStream.php#L141C1-L141C1).
There is an assumption a content-type is returned no matter what...

How to reproduce
Try to upload a multipart file without extension

Possible Solution
Add a default content-type for files without extensions l'île proposes in PR #566

Additional context

@GrahamCampbell
Copy link
Member

It doesn't assume that? The if ($type = MimeType::fromFilename($filename)) { will skip if there's no type.

@GrahamCampbell
Copy link
Member

Do we have to supply a default content type, if none makes sense?

@ReiatsuSan
Copy link
Author

Imho If no Content-Type could be determined application/octet-stream or anything like this seams a good fit.
As a user of guzzler to create my multipart requests does not let me change the content header. If there is a solution to set the Content-Type without loosing the boundary field I am ok with leaving the current behaviour...

@GrahamCampbell
Copy link
Member

Fixed in 2.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants