[英]How can I post base64 image data to a Discord webhook (without using discord.js)?
I've seen other question/answers on how to achieve this, but I do not want to use Discord.js (can't in my circumstance).我已经看到有关如何实现此目的的其他问题/答案,但我不想使用 Discord.js(在我的情况下不能)。 I have a webhook URL and base 64 image data, but cannot find helpful documentation or otherwise documented question/answers that tells me how to properly post that image information to the webhook.
我有一个 webhook URL 和 base 64 图像数据,但找不到有用的文档或以其他方式记录的问题/答案来告诉我如何正确地将该图像信息发布到 webhook。
Based on the documentation ( link ), it seems as if I should be able to use the embed
or file
properties of the payload, but all examples use a direct link to the image rather than the data.根据文档( 链接),似乎我应该能够使用有效负载的
embed
或file
属性,但所有示例都使用指向图像而不是数据的直接链接。
So I'm looking for the shape of the payload and what exactly form the image data should be in to be able to post via a Discord webhook.因此,我正在寻找有效载荷的形状以及图像数据的确切形式,以便能够通过 Discord webhook 发布。
Here's my payload from what I could gather from the docs (but this isn't correct):这是我从文档中收集到的有效负载(但这不正确):
I think it's should look like this, refer to the doc https://discord.com/developers/docs/reference#editing-message-attachments-example-request-bodies-multipartformdata我认为它应该看起来像这样,请参阅文档https://discord.com/developers/docs/reference#editing-message-attachments-example-request-bodies-multipartformdata
And it will take a lot of decode/encode work to make it right without sdk by the way.顺便说一句,在没有 sdk 的情况下,需要大量的解码/编码工作才能使其正确。
--boundary
Content-Disposition: form-data; name="payload_json"
Content-Type: application/json
{
"content": "Hello, World!",
"embeds": [{
"title": "Hello, Embed!",
"description": "This is an embedded message.",
"thumbnail": {
"url": "attachment://myfilename.png"
},
"image": {
"url": "attachment://mygif.gif"
}
}],
"message_reference": {
"message_id": "233648473390448641"
},
"attachments": [{
"id": 0,
"description": "Image of a cute little cat",
"filename": "file.png"
}, {
"id": 1,
"description": "Rickroll gif",
"filename": "mygif.gif"
}]
}
--boundary
Content-Disposition: form-data; name="files[0]"; filename="file.png"
Content-Type: image/png
[image bytes]
--boundary
Content-Disposition: form-data; name="files[1]"; filename="mygif.gif"
Content-Type: image/gif
[image bytes]
--boundary--
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.