-
-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix, feat: Add MIME type to HTTP file transfer API #643
Conversation
BREAKING CHANGES: ABI is broken due to function signature changes (API is preserved through the use of default parameters)
✅ Deploy Preview for dpp-dev ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
What sticker API do you mean? This one?: https://discord.com/developers/docs/resources/sticker#create-guild-sticker |
This one yes, and subsequently |
What was your code that didn't work? And what was the error message? |
I tested extensively, the content I retrieved through the sticker URL was valid, the resized image as well, I kept writing my data to a PNG file and it was working fine. Even uploading those processed PNG files through the discord app worked, while my bot didn't, even after re-reading the PNG files and uploading that data. Changing the MIME type is the only thing that worked. Discord was even accepting my files as an attachment to messages, which were displaying fine as well. It was only for stickers that it rejected it. |
I'm just curious because i can't find any mime type in discord's documentation |
Yeah 😆 I was really confused as well, my data was working fine, I thought I had all the requirements the API docs specified, except it kept rejecting my sticker through the bot. This could be a suggestion to send them for sure. |
As I found out the hard way on my bot B-12 while adding a command to add stickers, it turns out the sticker create API expects the file it receives to have a MIME type that corresponds to its data. I spent hours trying to troubleshoot my bot's code, but while digging into DPP code it became clear that the
application/octet-stream
MIME type it sent by default was what was causing the issue, as changing it toimage/png
allowed it to be accepted by the API.This pull request adds MIME types to APIs that deal with raw file uploading through the REST API. This includes data members in
dpp::http_request
, indpp::message
, and function signature changes. MIME type defaults toapplication/octet-stream
if unspecified by the user.This effectively :
text/plain
as type will have its text shown in the app, a file withapplication/octet-stream
will be available for download, and so on.Changes of note :
Tested on my own bot, on MSVC, clang-cl, Linux-GCC. Unit tests also pass (I also added the new MIME type parameters to it).