Incorrect file reference in API JSON return

Not sure if this is the right place to post this but

I was coding some API functions and found that when I make a request to https://badges.twitch.tv/v1/badges/global/display?language=en The request returns a JSON with


“broken-age_1”: {
“versions”: {
“1”: {
“image_url_1x”: “https://static-cdn.jtvnw.net/badges/v1/56885ed2-9a09-4c8e-8131-3eb9ec15af94/1”,
"image_url_2x": “https://static-cdn.jtvnw.net/badges/v1/56885ed2-9a09-4c8e-8131-3eb9ec15af94/2”,
“image_url_4x”: “https://static-cdn.jtvnw.net/badges/v1/56885ed2-9a09-4c8e-8131-3eb9ec15af94/3”,
“description”: “Broken Age”,
“title”: “Broken Age”,
“click_action”: “visit_url”,
“click_url”: “https://www.twitch.tv/directory/game/Broken%20Age/details
}
}
},

The image_url_2x URL should return a PNG file but is returning some other file type with a header with a lot of meta data. Possible some other image file type.

38 42 50 53 00 01 00 00    8BPS....

8BPS means “Adobe Photoshop file.” This is a valid Photoshop file when the file extension is .psd.

I figured it was some other type. Just odd that out of the 130+ images the request returns all but this one is a PNG.
I know this is a trivial matter. I will have to code around it as the project I am working on can’t display a PSD file , not without me coding some sort of importer .

Thanks

Ok now this is odd.
I was going to code around this spot by taking the response header from the download code and check the “Content-Type” but it is returning “image/png”.
So this appears to be some error on the server side maybe.

I don’t know what your application is of all 3 scales, but you could just use the 1x or 3x version in its place and scale it locally. If it’s a web application, HTML and CSS can scale it just fine. I could also provide you with the 2x version if you’d like. I’ll see about reporting this issue to someone if you don’t intend to. Should be an easy fix.

I have already implemented a work-around.
But my post was to inform on a possible mistake/error either in the API or the back end of the server housing the images.
If I can’t trust that the server is returning the type of file it reports in the return header then in cases where it returns a file type I don’t anticipate would lead to unresolved errors in my app.

Since I posted this thread I found another url for a different image returning a PSD file when the server is reporting it as a PNG. The images returned in the API appear to be adding more from time to time , it just added a whole new set recently.

I realize this is a small issue but it appears to be a legitimate error.
All I am saying is it would be nice if I could trust the process.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.