jellyfin / jellyfin

The Free Software Media System
https://jellyfin.org
GNU General Public License v2.0
33.51k stars 3.06k forks source link

Jellyfin API POST /Items/{itemId}/Images/{imageType} returns 400 "Incorrect ContentType." #12447

Closed JohnZ03 closed 1 month ago

JohnZ03 commented 1 month ago

This issue respects the following points:

Description of the bug

API Post /Items/{itemId}/Images/{imageType} Set item image keeps returning "Incorrect ContentType." Tested with different image formats through both built-in swagger and postman. After changing in header, Content-Type: image/* to Content-Type: image/png or any other format, server returns 500 "Error processing request."

Reproduction steps

Using the built in swagger, ex: http://{server-ip}/api-docs/swagger/index.html Item id being one of the movies. Image Type set to Primary. Request body set to a png/jpeg/jpg movie poster.

What is the current bug behavior?

400 server response, and the item image cannot be set.

What is the expected correct behavior?

200 server response, item's image updated.

Jellyfin Server version

Older*

Specify commit id

No response

Specify unstable release number

No response

Specify version number

10.9.8

Specify the build version

10.9.8

Environment

Docekr build

Jellyfin logs

N/A

FFmpeg logs

No response

Client / Browser logs

No response

Relevant screenshots or videos

No response

Additional information

No response

JohnZ03 commented 1 month ago

The "Incorrect ContentType." 400 response comes from the function below: https://github.com/jellyfin/jellyfin/blob/4363cbd88bd890bec8d1934bf93808ebaf461ff0/Jellyfin.Api/Controllers/ImageController.cs#L347-L372 Where it uses a parsing function to determine the file extension: https://github.com/jellyfin/jellyfin/blob/4363cbd88bd890bec8d1934bf93808ebaf461ff0/Jellyfin.Api/Controllers/ImageController.cs#L2124-L2142

If anyone have a testing environment, could you please check if the function "TryGetImageExtensionFromContentType" is behaving correctly?

I'm also trying to clone and test but it might take a while.

Thanks for any help in advance.

gnattu commented 1 month ago

From what you described I have an impression that you are using this API endpoint wrong.

JohnZ03 commented 1 month ago

Well thanks a lot, I did not see any part about the body type in the doc, will test and see if I can update the documentation as well. @gnattu

JohnZ03 commented 1 month ago

Can confirm it's working now, thanks so much for the help. @gnattu