Closed didinele closed 2 years ago
I also opened a discussion related to this a while ago https://github.com/discord/discord-api-docs/discussions/4941
It would be better if the type is automatically determined by discord.
image/apng
is not a mime type sadly, which is an example of why #4941 should be implemented.
Description
Perhaps this would be better fitted as a feature request? I'm unsure, so I'll just go on ahead and flag this as an issue:
Using
POST /guilds/guild.id/stickers
with the type of the file set toimage/apng
yields a 400 with the error code50046
-Invalid Asset
.For clarity, I do not mean the actual
Content-Type
header in the request - that is correctly set tomultipart/form-data
.image/png
works, so I'd generally not bother opening such an issue, but in the context of a library, we allow our users to pass in file data with no other metadata about it, in which case we rely on the magic bytes to infer its type. Our package of choice for inference,file-type
yieldsimage/apng
for this sort of file.User flagged issue in question: https://github.com/discordjs/discord.js/issues/8557
Steps to Reproduce
Unfortunately I can't think of an easy way to produce this with cURL when it comes to embedding the binary data into the request, so I'll be providing a very barebones node.js script using just undici to make the HTTP request.
mkdir content-type-repro
cd content-type-repro
npm init -y
npm install undici
touch index.js
& copy the following into it:node index.js
Now, if we were to do the following:
The sticker would be created successfully.
Expected Behavior
The sticker is created successfully even with
image/apng
.Current Behavior
The API returns a
400
with the following JSON body:400 { message: 'Invalid Asset', code: 50046 }
Screenshots/Videos
No response
Client and System Information
This issue can be reproduced with
discord.js
14.3.0
(@discordjs/rest
1.1.0
) due to the described content-type inference we do.My repro script uses
undici
5.8.2
and node.js16.11.0
.